This repository was archived by the owner on Apr 28, 2025. It is now read-only.
-
Couldn't load subscription status.
- Fork 55
Pre-compute aggregations to optimize scaling recording rules #284
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -197,6 +197,30 @@ local utils = import 'mixin-utils/utils.libsonnet'; | |
| ) | ||
| |||, | ||
| }, | ||
| { | ||
| // Convenience rule to get the CPU utilization for both a deployment and a statefulset. | ||
| record: 'cluster_namespace_deployment:container_cpu_usage_seconds_total:sum_rate', | ||
| expr: ||| | ||
| sum by (cluster, namespace, deployment) ( | ||
| label_replace( | ||
| node_namespace_pod_container:container_cpu_usage_seconds_total:sum_rate, | ||
| "deployment", "$1", "pod", "(.*)-(?:([0-9]+)|([a-z0-9]+)-([a-z0-9]+))" | ||
| ) | ||
| ) | ||
| |||, | ||
| }, | ||
| { | ||
| // Convenience rule to get the CPU request for both a deployment and a statefulset. | ||
| record: 'cluster_namespace_deployment:kube_pod_container_resource_requests_cpu_cores:sum', | ||
| expr: ||| | ||
| sum by (cluster, namespace, deployment) ( | ||
| label_replace( | ||
| kube_pod_container_resource_requests_cpu_cores, | ||
| "deployment", "$1", "pod", "(.*)-(?:([0-9]+)|([a-z0-9]+)-([a-z0-9]+))" | ||
| ) | ||
| ) | ||
| |||, | ||
| }, | ||
| { | ||
| // Jobs should be sized to their CPU usage. | ||
| // We do this by comparing 99th percentile usage over the last 24hrs to | ||
|
|
@@ -209,20 +233,32 @@ local utils = import 'mixin-utils/utils.libsonnet'; | |
| ceil( | ||
| cluster_namespace_deployment:actual_replicas:count | ||
| * | ||
| quantile_over_time(0.99, | ||
| sum by (cluster, namespace, deployment) ( | ||
| label_replace( | ||
| node_namespace_pod_container:container_cpu_usage_seconds_total:sum_rate, | ||
| "deployment", "$1", "pod", "(.*)-(?:([0-9]+)|([a-z0-9]+)-([a-z0-9]+))" | ||
| ) | ||
| )[24h:5m] | ||
| ) | ||
| quantile_over_time(0.99, cluster_namespace_deployment:container_cpu_usage_seconds_total:sum_rate[24h:5m]) | ||
| / | ||
| sum by (cluster, namespace, deployment) ( | ||
| label_replace( | ||
| kube_pod_container_resource_requests_cpu_cores, | ||
| "deployment", "$1", "pod", "(.*)-(?:([0-9]+)|([a-z0-9]+)-([a-z0-9]+))" | ||
| ) | ||
| cluster_namespace_deployment:kube_pod_container_resource_requests_cpu_cores:sum | ||
| ) | ||
| |||, | ||
| }, | ||
| { | ||
| // Convenience rule to get the Memory utilization for both a deployment and a statefulset. | ||
| record: 'cluster_namespace_deployment:container_memory_usage_bytes:sum', | ||
| expr: ||| | ||
| sum by (cluster, namespace, deployment) ( | ||
| label_replace( | ||
| container_memory_usage_bytes, | ||
| "deployment", "$1", "pod", "(.*)-(?:([0-9]+)|([a-z0-9]+)-([a-z0-9]+))" | ||
| ) | ||
| ) | ||
| |||, | ||
| }, | ||
| { | ||
| // Convenience rule to get the Memory request for both a deployment and a statefulset. | ||
| record: 'cluster_namespace_deployment:kube_pod_container_resource_requests_memory_bytes:sum', | ||
| expr: ||| | ||
| sum by (cluster, namespace, deployment) ( | ||
| label_replace( | ||
| kube_pod_container_resource_requests_memory_bytes, | ||
| "deployment", "$1", "pod", "(.*)-(?:([0-9]+)|([a-z0-9]+)-([a-z0-9]+))" | ||
| ) | ||
| ) | ||
| |||, | ||
|
|
@@ -239,21 +275,9 @@ local utils = import 'mixin-utils/utils.libsonnet'; | |
| ceil( | ||
| cluster_namespace_deployment:actual_replicas:count | ||
| * | ||
| quantile_over_time(0.99, | ||
| sum by (cluster, namespace, deployment) ( | ||
| label_replace( | ||
| container_memory_usage_bytes, | ||
| "deployment", "$1", "pod", "(.*)-(?:([0-9]+)|([a-z0-9]+)-([a-z0-9]+))" | ||
| ) | ||
| )[24h:5m] | ||
| ) | ||
| quantile_over_time(0.99, cluster_namespace_deployment:container_memory_usage_bytes:sum[24h:5m]) | ||
|
||
| / | ||
| sum by (cluster, namespace, deployment) ( | ||
| label_replace( | ||
| kube_pod_container_resource_requests_memory_bytes, | ||
| "deployment", "$1", "pod", "(.*)-(?:([0-9]+)|([a-z0-9]+)-([a-z0-9]+))" | ||
| ) | ||
| ) | ||
| cluster_namespace_deployment:kube_pod_container_resource_requests_memory_bytes:sum | ||
| ) | ||
| |||, | ||
| }, | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.