Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mimir source billing #456

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions class/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,8 @@ parameters:
vshn-appuio-mimir: true
prometheus:
url: http://vshn-appuio-mimir-query-frontend.vshn-appuio-mimir.svc:8080/prometheus
# TODO Change to 2 different sources instead of one
# Scrape APPUiO Cloud from APPUiOCloud Mimir source
# Scrape APPUiO Managed from APPUiOManaged OpenShift 4 Mimir source
# Currently both Cloud and Managed are in APPUiOManaged OpenShift 4 Mimir source
org_id: appuio-managed-openshift-billing
cloud_org_id: appuio-cloud-metering-c-appuio-cloudscale-lpg-2|appuio-cloud-metering-c-appuio-exoscale-ch-gva-2-0
managed_org_id: appuio-managed-openshift-billing
odoo:
url: "https://test.central.vshn.ch/api/v2/product_usage_report_POST"
oauth:
Expand Down
10 changes: 6 additions & 4 deletions component/billing.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,12 @@ local commonEnv = std.prune([
name: 'AR_PROM_URL',
value: paramsBilling.prometheus.url,
},
if paramsBilling.prometheus.org_id != null then {
name: 'AR_ORG_ID',
value: paramsBilling.prometheus.org_id,
},
]);

local backfillCJ = function(name, query, sla, type)

local orgId = if type == 'cloud' then paramsBilling.prometheus.cloud_org_id else paramsBilling.prometheus.managed_org_id;

local typeDesc = if type == 'cloud' then 'APPUiO Cloud - Zone: ' else 'APPUiO Managed - Cluster: ';

local itemDescJsonnet = 'local labels = std.extVar("labels"); "%s" %% labels' % '%(label_appcat_vshn_io_claim_name)s';
Expand All @@ -94,6 +92,10 @@ local backfillCJ = function(name, query, sla, type)
local productID = 'appcat-vshn-%(name)s-%(sla)s' % { name: name, sla: sla };

local jobEnv = std.prune([
{
name: 'AR_ORG_ID',
value: orgId,
},
{
name: 'AR_PRODUCT_ID',
value: productID,
Expand Down
24 changes: 12 additions & 12 deletions tests/golden/billing/appcat/appcat/billing/11_backfill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ spec:
- name: AR_PROM_URL
value: http://prometheus-operated.prometheus-system:9090/prometheus
- name: AR_ORG_ID
value: appuio-managed-openshift-billing
value: appuio-cloud-metering-c-appuio-cloudscale-lpg-2|appuio-cloud-metering-c-appuio-exoscale-ch-gva-2-0
- name: AR_PRODUCT_ID
value: appcat-vshn-keycloak-besteffort
- name: AR_QUERY
Expand Down Expand Up @@ -145,7 +145,7 @@ spec:
- name: AR_PROM_URL
value: http://prometheus-operated.prometheus-system:9090/prometheus
- name: AR_ORG_ID
value: appuio-managed-openshift-billing
value: appuio-cloud-metering-c-appuio-cloudscale-lpg-2|appuio-cloud-metering-c-appuio-exoscale-ch-gva-2-0
- name: AR_PRODUCT_ID
value: appcat-vshn-keycloak-guaranteed
- name: AR_QUERY
Expand Down Expand Up @@ -405,7 +405,7 @@ spec:
- name: AR_PROM_URL
value: http://prometheus-operated.prometheus-system:9090/prometheus
- name: AR_ORG_ID
value: appuio-managed-openshift-billing
value: appuio-cloud-metering-c-appuio-cloudscale-lpg-2|appuio-cloud-metering-c-appuio-exoscale-ch-gva-2-0
- name: AR_PRODUCT_ID
value: appcat-vshn-mariadb-besteffort
- name: AR_QUERY
Expand Down Expand Up @@ -493,7 +493,7 @@ spec:
- name: AR_PROM_URL
value: http://prometheus-operated.prometheus-system:9090/prometheus
- name: AR_ORG_ID
value: appuio-managed-openshift-billing
value: appuio-cloud-metering-c-appuio-cloudscale-lpg-2|appuio-cloud-metering-c-appuio-exoscale-ch-gva-2-0
- name: AR_PRODUCT_ID
value: appcat-vshn-mariadb-guaranteed
- name: AR_QUERY
Expand Down Expand Up @@ -753,7 +753,7 @@ spec:
- name: AR_PROM_URL
value: http://prometheus-operated.prometheus-system:9090/prometheus
- name: AR_ORG_ID
value: appuio-managed-openshift-billing
value: appuio-cloud-metering-c-appuio-cloudscale-lpg-2|appuio-cloud-metering-c-appuio-exoscale-ch-gva-2-0
- name: AR_PRODUCT_ID
value: appcat-vshn-minio-besteffort
- name: AR_QUERY
Expand Down Expand Up @@ -841,7 +841,7 @@ spec:
- name: AR_PROM_URL
value: http://prometheus-operated.prometheus-system:9090/prometheus
- name: AR_ORG_ID
value: appuio-managed-openshift-billing
value: appuio-cloud-metering-c-appuio-cloudscale-lpg-2|appuio-cloud-metering-c-appuio-exoscale-ch-gva-2-0
- name: AR_PRODUCT_ID
value: appcat-vshn-minio-guaranteed
- name: AR_QUERY
Expand Down Expand Up @@ -1101,7 +1101,7 @@ spec:
- name: AR_PROM_URL
value: http://prometheus-operated.prometheus-system:9090/prometheus
- name: AR_ORG_ID
value: appuio-managed-openshift-billing
value: appuio-cloud-metering-c-appuio-cloudscale-lpg-2|appuio-cloud-metering-c-appuio-exoscale-ch-gva-2-0
- name: AR_PRODUCT_ID
value: appcat-vshn-nextcloud-besteffort
- name: AR_QUERY
Expand Down Expand Up @@ -1189,7 +1189,7 @@ spec:
- name: AR_PROM_URL
value: http://prometheus-operated.prometheus-system:9090/prometheus
- name: AR_ORG_ID
value: appuio-managed-openshift-billing
value: appuio-cloud-metering-c-appuio-cloudscale-lpg-2|appuio-cloud-metering-c-appuio-exoscale-ch-gva-2-0
- name: AR_PRODUCT_ID
value: appcat-vshn-nextcloud-guaranteed
- name: AR_QUERY
Expand Down Expand Up @@ -1449,7 +1449,7 @@ spec:
- name: AR_PROM_URL
value: http://prometheus-operated.prometheus-system:9090/prometheus
- name: AR_ORG_ID
value: appuio-managed-openshift-billing
value: appuio-cloud-metering-c-appuio-cloudscale-lpg-2|appuio-cloud-metering-c-appuio-exoscale-ch-gva-2-0
- name: AR_PRODUCT_ID
value: appcat-vshn-postgres-besteffort
- name: AR_QUERY
Expand Down Expand Up @@ -1537,7 +1537,7 @@ spec:
- name: AR_PROM_URL
value: http://prometheus-operated.prometheus-system:9090/prometheus
- name: AR_ORG_ID
value: appuio-managed-openshift-billing
value: appuio-cloud-metering-c-appuio-cloudscale-lpg-2|appuio-cloud-metering-c-appuio-exoscale-ch-gva-2-0
- name: AR_PRODUCT_ID
value: appcat-vshn-postgres-guaranteed
- name: AR_QUERY
Expand Down Expand Up @@ -1797,7 +1797,7 @@ spec:
- name: AR_PROM_URL
value: http://prometheus-operated.prometheus-system:9090/prometheus
- name: AR_ORG_ID
value: appuio-managed-openshift-billing
value: appuio-cloud-metering-c-appuio-cloudscale-lpg-2|appuio-cloud-metering-c-appuio-exoscale-ch-gva-2-0
- name: AR_PRODUCT_ID
value: appcat-vshn-redis-besteffort
- name: AR_QUERY
Expand Down Expand Up @@ -1885,7 +1885,7 @@ spec:
- name: AR_PROM_URL
value: http://prometheus-operated.prometheus-system:9090/prometheus
- name: AR_ORG_ID
value: appuio-managed-openshift-billing
value: appuio-cloud-metering-c-appuio-cloudscale-lpg-2|appuio-cloud-metering-c-appuio-exoscale-ch-gva-2-0
- name: AR_PRODUCT_ID
value: appcat-vshn-redis-guaranteed
- name: AR_QUERY
Expand Down