Skip to content

Commit

Permalink
Merge pull request #138 from appuio/updating_appcat_query
Browse files Browse the repository at this point in the history
Update AppCat VSHN PostgreSQL and VSHN Redis query to new pricing model
  • Loading branch information
wejdross committed May 10, 2023
2 parents 9c88303 + 0b82cdd commit 735a7f3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,8 @@ clean: docker-compose-down ## Cleans local build artifacts
tar -xzf .cache/prometheus.tar.gz -C .cache
mv .cache/prometheus-$(PROMETHEUS_VERSION).$(PROMETHEUS_DIST)-$(PROMETHEUS_ARCH) .cache/prometheus
rm -rf .cache/*.tar.gz

# current date in UTC in ISO 8601 format (RFC 3339) with Z as timezone that works on both linux and macos
.PHONY: current-date
current-date:
date -u +"%Y-%m-%dT%H:%M:%SZ"
12 changes: 6 additions & 6 deletions pkg/db/seeds.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,22 @@ var DefaultQueries = []Query{
var renderedQueries = []RenderedQuery{
{
Query: Query{
Name: "appcat_postgresql_vshn_standalone",
Description: "Number of VSHN managed standalone postgres instances",
Name: "appcat_postgresql_by_vshn",
Description: "Number of VSHN managed postgres instances",
Unit: "Instances",
},
ProductName: "postgres",
ServiceName: "postgresql-standalone",
ServiceName: "appcat-postgresql",
Template: appcatVSHNTemplate,
},
{
Query: Query{
Name: "appcat_redis_vshn_standalone",
Description: "Number of VSHN managed standalone redis instances",
Name: "appcat_redis_by_vshn",
Description: "Number of VSHN managed redis instances",
Unit: "Instances",
},
ProductName: "redis",
ServiceName: "redis-standalone",
ServiceName: "appcat-redis",
Template: appcatVSHNTemplate,
},
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/db/seeds/appcat_vshn.promql.tmpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sum by (label_appuio_io_organization,label_appcat_vshn_io_claim_namespace,label_appcat_vshn_io_sla,product,provider,architecture, category, claim_namespace,tenant_id) (
# Sum values over one hour and get mean
sum_over_time(
# Udpate label product: $product:$provider:$tenant_id:$claim_namespace:$architecture
Expand All @@ -16,8 +17,8 @@ sum_over_time(
label_replace(
# Copy label appuio.io/organization to label tenant_id
label_replace(
# Fetch all namespaces with label appcat.vshn.io/servicename="{{.ServiceName}}"
kube_namespace_labels{label_appuio_io_organization=~".+", label_appcat_vshn_io_servicename="{{.ServiceName}}"},
# Fetch all namespaces with label appcat.vshn.io/billing-name="{{.ServiceName}}"
kube_namespace_labels{label_appuio_io_organization=~".+", label_appcat_vshn_io_billing_name="{{.ServiceName}}"} * on (namespace) group_right(label_appuio_io_organization,label_appcat_vshn_io_claim_namespace,label_appcat_vshn_io_sla,product,provider,architecture, category, claim_namespace, tenant_id) kube_pod_info{created_by_kind!="Job"},
"tenant_id",
"$1",
"label_appuio_io_organization",
Expand Down Expand Up @@ -61,4 +62,4 @@ sum_over_time(
"claim_namespace",
"architecture"
)[59m:1m]
)/60
)/60 )

0 comments on commit 735a7f3

Please sign in to comment.