Skip to content

Commit

Permalink
Merge pull request #521 from vshn/fix-billing-cloud-query
Browse files Browse the repository at this point in the history
Fix cloud billing query
  • Loading branch information
zugao authored Oct 29, 2024
2 parents ba33c2f + 57a308c commit d113c15
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion component/billing.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ local generateCloudAndManaged = function(name)
local queryName = if name == 'postgres' then name + 'ql' else name;

local managedQuery = 'sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-' + queryName + '",label_appcat_vshn_io_sla="%s", tenant_name!="APPUiO"}[59m:1m])/60';
local cloudQuery = 'sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-' + queryName + '",label_appcat_vshn_io_sla="%s", tenant_name="APPUiO"} * on(label_appuio_io_organization) group_left(sales_order) label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"}, "label_appuio_io_organization", "$1", "organization", "(.*)")[59m:1m])/60';
local cloudQuery = 'sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-' + queryName + '",label_appcat_vshn_io_sla="%s", tenant_name="APPUiO"}[59m:1m])/60 * on(label_appuio_io_organization) group_left(sales_order) label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"}, "label_appuio_io_organization", "$1", "organization", "(.*)")';

local permutations = [
{
Expand Down
72 changes: 36 additions & 36 deletions tests/golden/billing/appcat/appcat/billing/11_backfill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ spec:
value: appcat-vshn-keycloak-besteffort
- name: AR_QUERY
value: sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-keycloak",label_appcat_vshn_io_sla="besteffort",
tenant_name="APPUiO"} * on(label_appuio_io_organization) group_left(sales_order)
label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")[59m:1m])/60
tenant_name="APPUiO"}[59m:1m])/60 * on(label_appuio_io_organization)
group_left(sales_order) label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")
- name: AR_INSTANCE_JSONNET
value: local labels = std.extVar("labels"); "%(cluster_id)s/%(label_appcat_vshn_io_claim_namespace)s/%(label_appcat_vshn_io_claim_name)s"
% labels
Expand Down Expand Up @@ -150,9 +150,9 @@ spec:
value: appcat-vshn-keycloak-guaranteed
- name: AR_QUERY
value: sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-keycloak",label_appcat_vshn_io_sla="guaranteed",
tenant_name="APPUiO"} * on(label_appuio_io_organization) group_left(sales_order)
label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")[59m:1m])/60
tenant_name="APPUiO"}[59m:1m])/60 * on(label_appuio_io_organization)
group_left(sales_order) label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")
- name: AR_INSTANCE_JSONNET
value: local labels = std.extVar("labels"); "%(cluster_id)s/%(label_appcat_vshn_io_claim_namespace)s/%(label_appcat_vshn_io_claim_name)s"
% labels
Expand Down Expand Up @@ -410,9 +410,9 @@ spec:
value: appcat-vshn-mariadb-besteffort
- name: AR_QUERY
value: sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-mariadb",label_appcat_vshn_io_sla="besteffort",
tenant_name="APPUiO"} * on(label_appuio_io_organization) group_left(sales_order)
label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")[59m:1m])/60
tenant_name="APPUiO"}[59m:1m])/60 * on(label_appuio_io_organization)
group_left(sales_order) label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")
- name: AR_INSTANCE_JSONNET
value: local labels = std.extVar("labels"); "%(cluster_id)s/%(label_appcat_vshn_io_claim_namespace)s/%(label_appcat_vshn_io_claim_name)s"
% labels
Expand Down Expand Up @@ -498,9 +498,9 @@ spec:
value: appcat-vshn-mariadb-guaranteed
- name: AR_QUERY
value: sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-mariadb",label_appcat_vshn_io_sla="guaranteed",
tenant_name="APPUiO"} * on(label_appuio_io_organization) group_left(sales_order)
label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")[59m:1m])/60
tenant_name="APPUiO"}[59m:1m])/60 * on(label_appuio_io_organization)
group_left(sales_order) label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")
- name: AR_INSTANCE_JSONNET
value: local labels = std.extVar("labels"); "%(cluster_id)s/%(label_appcat_vshn_io_claim_namespace)s/%(label_appcat_vshn_io_claim_name)s"
% labels
Expand Down Expand Up @@ -758,9 +758,9 @@ spec:
value: appcat-vshn-minio-besteffort
- name: AR_QUERY
value: sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-minio",label_appcat_vshn_io_sla="besteffort",
tenant_name="APPUiO"} * on(label_appuio_io_organization) group_left(sales_order)
label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")[59m:1m])/60
tenant_name="APPUiO"}[59m:1m])/60 * on(label_appuio_io_organization)
group_left(sales_order) label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")
- name: AR_INSTANCE_JSONNET
value: local labels = std.extVar("labels"); "%(cluster_id)s/%(label_appcat_vshn_io_claim_namespace)s/%(label_appcat_vshn_io_claim_name)s"
% labels
Expand Down Expand Up @@ -846,9 +846,9 @@ spec:
value: appcat-vshn-minio-guaranteed
- name: AR_QUERY
value: sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-minio",label_appcat_vshn_io_sla="guaranteed",
tenant_name="APPUiO"} * on(label_appuio_io_organization) group_left(sales_order)
label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")[59m:1m])/60
tenant_name="APPUiO"}[59m:1m])/60 * on(label_appuio_io_organization)
group_left(sales_order) label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")
- name: AR_INSTANCE_JSONNET
value: local labels = std.extVar("labels"); "%(cluster_id)s/%(label_appcat_vshn_io_claim_namespace)s/%(label_appcat_vshn_io_claim_name)s"
% labels
Expand Down Expand Up @@ -1106,9 +1106,9 @@ spec:
value: appcat-vshn-nextcloud-besteffort
- name: AR_QUERY
value: sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-nextcloud",label_appcat_vshn_io_sla="besteffort",
tenant_name="APPUiO"} * on(label_appuio_io_organization) group_left(sales_order)
label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")[59m:1m])/60
tenant_name="APPUiO"}[59m:1m])/60 * on(label_appuio_io_organization)
group_left(sales_order) label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")
- name: AR_INSTANCE_JSONNET
value: local labels = std.extVar("labels"); "%(cluster_id)s/%(label_appcat_vshn_io_claim_namespace)s/%(label_appcat_vshn_io_claim_name)s"
% labels
Expand Down Expand Up @@ -1194,9 +1194,9 @@ spec:
value: appcat-vshn-nextcloud-guaranteed
- name: AR_QUERY
value: sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-nextcloud",label_appcat_vshn_io_sla="guaranteed",
tenant_name="APPUiO"} * on(label_appuio_io_organization) group_left(sales_order)
label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")[59m:1m])/60
tenant_name="APPUiO"}[59m:1m])/60 * on(label_appuio_io_organization)
group_left(sales_order) label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")
- name: AR_INSTANCE_JSONNET
value: local labels = std.extVar("labels"); "%(cluster_id)s/%(label_appcat_vshn_io_claim_namespace)s/%(label_appcat_vshn_io_claim_name)s"
% labels
Expand Down Expand Up @@ -1454,9 +1454,9 @@ spec:
value: appcat-vshn-postgres-besteffort
- name: AR_QUERY
value: sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-postgresql",label_appcat_vshn_io_sla="besteffort",
tenant_name="APPUiO"} * on(label_appuio_io_organization) group_left(sales_order)
label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")[59m:1m])/60
tenant_name="APPUiO"}[59m:1m])/60 * on(label_appuio_io_organization)
group_left(sales_order) label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")
- name: AR_INSTANCE_JSONNET
value: local labels = std.extVar("labels"); "%(cluster_id)s/%(label_appcat_vshn_io_claim_namespace)s/%(label_appcat_vshn_io_claim_name)s"
% labels
Expand Down Expand Up @@ -1542,9 +1542,9 @@ spec:
value: appcat-vshn-postgres-guaranteed
- name: AR_QUERY
value: sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-postgresql",label_appcat_vshn_io_sla="guaranteed",
tenant_name="APPUiO"} * on(label_appuio_io_organization) group_left(sales_order)
label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")[59m:1m])/60
tenant_name="APPUiO"}[59m:1m])/60 * on(label_appuio_io_organization)
group_left(sales_order) label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")
- name: AR_INSTANCE_JSONNET
value: local labels = std.extVar("labels"); "%(cluster_id)s/%(label_appcat_vshn_io_claim_namespace)s/%(label_appcat_vshn_io_claim_name)s"
% labels
Expand Down Expand Up @@ -1802,9 +1802,9 @@ spec:
value: appcat-vshn-redis-besteffort
- name: AR_QUERY
value: sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-redis",label_appcat_vshn_io_sla="besteffort",
tenant_name="APPUiO"} * on(label_appuio_io_organization) group_left(sales_order)
label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")[59m:1m])/60
tenant_name="APPUiO"}[59m:1m])/60 * on(label_appuio_io_organization)
group_left(sales_order) label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")
- name: AR_INSTANCE_JSONNET
value: local labels = std.extVar("labels"); "%(cluster_id)s/%(label_appcat_vshn_io_claim_namespace)s/%(label_appcat_vshn_io_claim_name)s"
% labels
Expand Down Expand Up @@ -1890,9 +1890,9 @@ spec:
value: appcat-vshn-redis-guaranteed
- name: AR_QUERY
value: sum_over_time(appcat:metering{label_appuio_io_billing_name="appcat-redis",label_appcat_vshn_io_sla="guaranteed",
tenant_name="APPUiO"} * on(label_appuio_io_organization) group_left(sales_order)
label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")[59m:1m])/60
tenant_name="APPUiO"}[59m:1m])/60 * on(label_appuio_io_organization)
group_left(sales_order) label_replace(appuio_control_organization_info{namespace="appuio-control-api-production"},
"label_appuio_io_organization", "$1", "organization", "(.*)")
- name: AR_INSTANCE_JSONNET
value: local labels = std.extVar("labels"); "%(cluster_id)s/%(label_appcat_vshn_io_claim_namespace)s/%(label_appcat_vshn_io_claim_name)s"
% labels
Expand Down

0 comments on commit d113c15

Please sign in to comment.