diff --git a/component/billing.jsonnet b/component/billing.jsonnet index 1f12d54d5..943df0b3b 100644 --- a/component/billing.jsonnet +++ b/component/billing.jsonnet @@ -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 = [ { diff --git a/tests/golden/billing/appcat/appcat/billing/11_backfill.yaml b/tests/golden/billing/appcat/appcat/billing/11_backfill.yaml index 2ca60b2c3..a21d328b3 100644 --- a/tests/golden/billing/appcat/appcat/billing/11_backfill.yaml +++ b/tests/golden/billing/appcat/appcat/billing/11_backfill.yaml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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