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

Add namespace label fix to subqueries too #113

Merged
merged 2 commits into from
Dec 23, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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