Skip to content

Commit

Permalink
Merge pull request #113 from appuio/fix-subqueries-ns-changes
Browse files Browse the repository at this point in the history
Add namespace label fix to subqueries too
  • Loading branch information
bastjan committed Dec 23, 2022
2 parents 4a1df2f + 9cd3cfc commit 5829fc3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pkg/db/seeds/appuio_cloud_memory.promql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Sum values over one hour.
sum_over_time(
# Average over a one-minute time frame.
# NOTE: This is a sliding window. Results vary based on the queries' execution time.
# NOTE: This is a sliding window. Results vary based on the queries execution time.
avg_over_time(
# Add the final product label by joining the base product with the cluster ID, the tenant and the namespace.
label_join(
Expand Down
18 changes: 12 additions & 6 deletions pkg/db/seeds/appuio_cloud_memory_sub_cpu.promql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Sum values over one hour.
sum_over_time(
# Average over a one-minute time frame.
# NOTE: This is a sliding window. Results vary based on the queries' execution time.
# NOTE: This is a sliding window. Results vary based on the queries execution time.
avg_over_time(
# Add the final product label by joining the base product with the cluster ID, the tenant and the namespace.
label_join(
Expand Down Expand Up @@ -33,11 +33,17 @@ sum_over_time(
# Join namespace label `label_appuio_io_organization` as `tenant_id`.
on(cluster_id, namespace)
group_left(tenant_id)
label_replace(
kube_namespace_labels{label_appuio_io_organization=~".+"},
"tenant_id",
"$1",
"label_appuio_io_organization", "(.*)"
(
bottomk(1,
min by (cluster_id, namespace, tenant_id) (
label_replace(
kube_namespace_labels{label_appuio_io_organization=~".+"},
"tenant_id",
"$1",
"label_appuio_io_organization", "(.*)"
)
)
) by(cluster_id, namespace)
),
# At least return 0
0
Expand Down
18 changes: 12 additions & 6 deletions pkg/db/seeds/appuio_cloud_memory_sub_memory.promql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Sum values over one hour.
sum_over_time(
# Average over a one-minute time frame.
# NOTE: This is a sliding window. Results vary based on the queries' execution time.
# NOTE: This is a sliding window. Results vary based on the queries execution time.
avg_over_time(
# Add the final product label by joining the base product with the cluster ID, the tenant and the namespace.
label_join(
Expand All @@ -28,11 +28,17 @@ sum_over_time(
# Join namespace label `label_appuio_io_organization` as `tenant_id`.
on(cluster_id, namespace)
group_left(tenant_id)
label_replace(
kube_namespace_labels{label_appuio_io_organization=~".+"},
"tenant_id",
"$1",
"label_appuio_io_organization", "(.*)"
(
bottomk(1,
min by (cluster_id, namespace, tenant_id) (
label_replace(
kube_namespace_labels{label_appuio_io_organization=~".+"},
"tenant_id",
"$1",
"label_appuio_io_organization", "(.*)"
)
)
) by(cluster_id, namespace)
),
"product",
"appuio_cloud_memory",
Expand Down

0 comments on commit 5829fc3

Please sign in to comment.