-
Notifications
You must be signed in to change notification settings - Fork 55
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
Fix scaling dashboard to work on multi-zone ingesters #365
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -69,12 +69,21 @@ local utils = import 'mixin-utils/utils.libsonnet'; | |||||||||||
rules: [ | ||||||||||||
{ | ||||||||||||
// Convenience rule to get the number of replicas for both a deployment and a statefulset. | ||||||||||||
// Multi-zone deployments are grouped together removing the "zone-X" suffix. | ||||||||||||
record: 'cluster_namespace_deployment:actual_replicas:count', | ||||||||||||
expr: ||| | ||||||||||||
sum by (cluster, namespace, deployment) (kube_deployment_spec_replicas) | ||||||||||||
or | ||||||||||||
sum by (cluster, namespace, deployment) ( | ||||||||||||
label_replace(kube_statefulset_replicas, "deployment", "$1", "statefulset", "(.*)") | ||||||||||||
label_replace( | ||||||||||||
kube_deployment_spec_replicas, | ||||||||||||
"deployment", "$1", "deployment", "(.*?)(?:-zone-[a-z])?" | ||||||||||||
) | ||||||||||||
) | ||||||||||||
or | ||||||||||||
sum by (cluster, namespace, deployment) ( | ||||||||||||
label_replace( | ||||||||||||
label_replace(kube_statefulset_replicas, "deployment", "$1", "statefulset", "(.*)"), | ||||||||||||
"deployment", "$1", "deployment", "(.*?)(?:-zone-[a-z])?" | ||||||||||||
) | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The inner label replace is just moving the
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's right. I've applied the suggested change and manually tested it. |
||||||||||||
) | ||||||||||||
|||, | ||||||||||||
}, | ||||||||||||
|
@@ -188,7 +197,7 @@ local utils = import 'mixin-utils/utils.libsonnet'; | |||||||||||
expr: ||| | ||||||||||||
ceil( | ||||||||||||
(sum by (cluster, namespace) ( | ||||||||||||
cortex_ingester_tsdb_storage_blocks_bytes{job=~".+/ingester"} | ||||||||||||
cortex_ingester_tsdb_storage_blocks_bytes{job=~".+/ingester.*"} | ||||||||||||
) / 4) | ||||||||||||
/ | ||||||||||||
avg by (cluster, namespace) ( | ||||||||||||
|
@@ -199,18 +208,23 @@ local utils = import 'mixin-utils/utils.libsonnet'; | |||||||||||
}, | ||||||||||||
{ | ||||||||||||
// Convenience rule to get the CPU utilization for both a deployment and a statefulset. | ||||||||||||
// Multi-zone deployments are grouped together removing the "zone-X" suffix. | ||||||||||||
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]+))" | ||||||||||||
label_replace( | ||||||||||||
node_namespace_pod_container:container_cpu_usage_seconds_total:sum_rate, | ||||||||||||
"deployment", "$1", "pod", "(.*)-(?:([0-9]+)|([a-z0-9]+)-([a-z0-9]+))" | ||||||||||||
), | ||||||||||||
"deployment", "$1", "deployment", "(.*?)(?:-zone-[a-z])?" | ||||||||||||
) | ||||||||||||
) | ||||||||||||
|||, | ||||||||||||
}, | ||||||||||||
{ | ||||||||||||
// Convenience rule to get the CPU request for both a deployment and a statefulset. | ||||||||||||
// Multi-zone deployments are grouped together removing the "zone-X" suffix. | ||||||||||||
record: 'cluster_namespace_deployment:kube_pod_container_resource_requests_cpu_cores:sum', | ||||||||||||
expr: ||| | ||||||||||||
# This recording rule is made compatible with the breaking changes introduced in kube-state-metrics v2 | ||||||||||||
|
@@ -223,8 +237,11 @@ local utils = import 'mixin-utils/utils.libsonnet'; | |||||||||||
( | ||||||||||||
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]+))" | ||||||||||||
label_replace( | ||||||||||||
kube_pod_container_resource_requests_cpu_cores, | ||||||||||||
"deployment", "$1", "pod", "(.*)-(?:([0-9]+)|([a-z0-9]+)-([a-z0-9]+))" | ||||||||||||
), | ||||||||||||
"deployment", "$1", "deployment", "(.*?)(?:-zone-[a-z])?" | ||||||||||||
) | ||||||||||||
) | ||||||||||||
) | ||||||||||||
|
@@ -234,8 +251,11 @@ local utils = import 'mixin-utils/utils.libsonnet'; | |||||||||||
( | ||||||||||||
sum by (cluster, namespace, deployment) ( | ||||||||||||
label_replace( | ||||||||||||
kube_pod_container_resource_requests{resource="cpu"}, | ||||||||||||
"deployment", "$1", "pod", "(.*)-(?:([0-9]+)|([a-z0-9]+)-([a-z0-9]+))" | ||||||||||||
label_replace( | ||||||||||||
kube_pod_container_resource_requests{resource="cpu"}, | ||||||||||||
"deployment", "$1", "pod", "(.*)-(?:([0-9]+)|([a-z0-9]+)-([a-z0-9]+))" | ||||||||||||
), | ||||||||||||
"deployment", "$1", "deployment", "(.*?)(?:-zone-[a-z])?" | ||||||||||||
) | ||||||||||||
) | ||||||||||||
) | ||||||||||||
|
@@ -261,18 +281,23 @@ local utils = import 'mixin-utils/utils.libsonnet'; | |||||||||||
}, | ||||||||||||
{ | ||||||||||||
// Convenience rule to get the Memory utilization for both a deployment and a statefulset. | ||||||||||||
// Multi-zone deployments are grouped together removing the "zone-X" suffix. | ||||||||||||
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]+))" | ||||||||||||
label_replace( | ||||||||||||
container_memory_usage_bytes, | ||||||||||||
"deployment", "$1", "pod", "(.*)-(?:([0-9]+)|([a-z0-9]+)-([a-z0-9]+))" | ||||||||||||
), | ||||||||||||
"deployment", "$1", "deployment", "(.*?)(?:-zone-[a-z])?" | ||||||||||||
) | ||||||||||||
) | ||||||||||||
|||, | ||||||||||||
}, | ||||||||||||
{ | ||||||||||||
// Convenience rule to get the Memory request for both a deployment and a statefulset. | ||||||||||||
// Multi-zone deployments are grouped together removing the "zone-X" suffix. | ||||||||||||
record: 'cluster_namespace_deployment:kube_pod_container_resource_requests_memory_bytes:sum', | ||||||||||||
expr: ||| | ||||||||||||
# This recording rule is made compatible with the breaking changes introduced in kube-state-metrics v2 | ||||||||||||
|
@@ -285,8 +310,11 @@ local utils = import 'mixin-utils/utils.libsonnet'; | |||||||||||
( | ||||||||||||
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]+))" | ||||||||||||
label_replace( | ||||||||||||
kube_pod_container_resource_requests_memory_bytes, | ||||||||||||
"deployment", "$1", "pod", "(.*)-(?:([0-9]+)|([a-z0-9]+)-([a-z0-9]+))" | ||||||||||||
), | ||||||||||||
"deployment", "$1", "deployment", "(.*?)(?:-zone-[a-z])?" | ||||||||||||
) | ||||||||||||
) | ||||||||||||
) | ||||||||||||
|
@@ -296,8 +324,11 @@ local utils = import 'mixin-utils/utils.libsonnet'; | |||||||||||
( | ||||||||||||
sum by (cluster, namespace, deployment) ( | ||||||||||||
label_replace( | ||||||||||||
kube_pod_container_resource_requests{resource="memory"}, | ||||||||||||
"deployment", "$1", "pod", "(.*)-(?:([0-9]+)|([a-z0-9]+)-([a-z0-9]+))" | ||||||||||||
label_replace( | ||||||||||||
kube_pod_container_resource_requests{resource="memory"}, | ||||||||||||
"deployment", "$1", "pod", "(.*)-(?:([0-9]+)|([a-z0-9]+)-([a-z0-9]+))" | ||||||||||||
), | ||||||||||||
"deployment", "$1", "deployment", "(.*?)(?:-zone-[a-z])?" | ||||||||||||
) | ||||||||||||
) | ||||||||||||
) | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the first question mark necessary? Shouldn't it be:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first question mark is to make it non-greedy. Since the
(?:-zone-[a-z])?
is optional (ending?
), if the first(.*)
is greedy then it always match everything and never removes the zone. Adding(.*?)
we make the first.*
non greedy.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL! Can you add a comment to this effect please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, done.