diff --git a/pkg/db/seeds/appuio_cloud_memory.promql b/pkg/db/seeds/appuio_cloud_memory.promql index de4f598..112a36d 100644 --- a/pkg/db/seeds/appuio_cloud_memory.promql +++ b/pkg/db/seeds/appuio_cloud_memory.promql @@ -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( diff --git a/pkg/db/seeds/appuio_cloud_memory_sub_cpu.promql b/pkg/db/seeds/appuio_cloud_memory_sub_cpu.promql index aaa5f21..7e1d425 100644 --- a/pkg/db/seeds/appuio_cloud_memory_sub_cpu.promql +++ b/pkg/db/seeds/appuio_cloud_memory_sub_cpu.promql @@ -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( @@ -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 diff --git a/pkg/db/seeds/appuio_cloud_memory_sub_memory.promql b/pkg/db/seeds/appuio_cloud_memory_sub_memory.promql index 85f80bb..c83e3ca 100644 --- a/pkg/db/seeds/appuio_cloud_memory_sub_memory.promql +++ b/pkg/db/seeds/appuio_cloud_memory_sub_memory.promql @@ -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( @@ -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",