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

Update AppCat VSHN PostgreSQL and VSHN Redis query to new pricing model #138

Merged
merged 5 commits into from
May 10, 2023
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
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 )