feat: add memory drift and trend alerts for kube-applier#6011
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: weherdh The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Pull request overview
Adds proactive memory drift/trend alerting for the kube-applier workload so the Service Lifecycle team can detect sustained memory growth and adjust requests before OOMs occur.
Changes:
- Introduces
KubeApplierMemoryDriftandKubeApplierMemoryTrendPrometheusRule alerts based on working set vs. memory requests. - Adds promtool unit tests for the new rule file (currently only covers drift; trend test coverage needs to be added).
- Wires the new rule into the alert build pipeline and updates the generated Azure Monitor PrometheusRuleGroup Bicep output.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| observability/alerts/kubeApplierResources-prometheusRule.yaml | New PrometheusRule defining drift and trend memory alerts for kube-applier. |
| observability/alerts/kubeApplierResources-prometheusRule_test.yaml | New promtool unit tests for the kube-applier resource alerts (needs trend coverage). |
| observability/alerts-sl-services.yaml | Registers the new kube-applier alert rule file for generation/testing. |
| dev-infrastructure/modules/metrics/rules/generatedPrometheusAlertingRules.bicep | Generated deployment output including the new kube-applier alert rule group. |
Comments suppressed due to low confidence (1)
observability/alerts/kubeApplierResources-prometheusRule_test.yaml:41
- The PR adds two alerts, but the promtool unit tests here only cover KubeApplierMemoryDrift. Add at least a firing and non-firing test case for KubeApplierMemoryTrend so regressions in the predict_linear expression or annotations are caught.
alert_rule_test:
- eval_time: 15m
alertname: KubeApplierMemoryDrift
exp_alerts: []
| ( | ||
| container_memory_working_set_bytes{container="kube-applier", namespace="kube-applier"} | ||
| / on(namespace, pod, container, cluster) | ||
| kube_pod_container_resource_requests{container="kube-applier", namespace="kube-applier", resource="memory"} | ||
| ) > 1.5 |
| predict_linear( | ||
| container_memory_working_set_bytes{container="kube-applier", namespace="kube-applier"}[6h], 4 * 3600 | ||
| ) | ||
| / on(namespace, pod, container, cluster) | ||
| kube_pod_container_resource_requests{container="kube-applier", namespace="kube-applier", resource="memory"} |
| annotations: | ||
| summary: kube-applier memory exceeds 1.5x its request on cluster {{ $labels.cluster }}. | ||
| description: | | ||
| kube-applier pod {{ $labels.pod }} on cluster {{ $labels.cluster }} is using {{ $value | humanizePercentage }} of its memory request for more than 15 minutes. | ||
| This may indicate a memory leak or workload growth that requires right-sizing the request in config.yaml. | ||
| owning_team: hcp-sl |
| annotations: | ||
| summary: kube-applier memory trending toward 2x its request on cluster {{ $labels.cluster }}. | ||
| description: | | ||
| kube-applier pod {{ $labels.pod }} on cluster {{ $labels.cluster }} memory is growing steadily. | ||
| At the current rate over the past 6 hours, it will exceed 2x its memory request within 4 hours. | ||
| Investigate for potential memory leaks or increased workload. | ||
| owning_team: hcp-sl |
kube-applier has no proactive alerting for memory growth today. Add two PrometheusRule alerts so we can right-size the request before an OOM occurs: - KubeApplierMemoryDrift (warning): fires when working set exceeds 1.5x the memory request for 15 minutes. - KubeApplierMemoryTrend (info): fires when predict_linear over 6h projects memory will exceed 2x the request within 4 hours. Uses max by() on kube_pod_container_resource_requests with job="kube-state-metrics" filter to safely handle potential kube-state-metrics replication. Ref: AROSLSRE-1068
c1a32a1 to
24fb306
Compare
| values: "134217728+1048576x390" | ||
| - series: 'kube_pod_container_resource_requests{container="kube-applier", namespace="kube-applier", pod="kube-applier-0", cluster="test", resource="memory", job="kube-state-metrics"}' | ||
| values: "134217728+0x390" |
| values: "134217728+0x390" | ||
| - series: 'kube_pod_container_resource_requests{container="kube-applier", namespace="kube-applier", pod="kube-applier-0", cluster="test", resource="memory", job="kube-state-metrics"}' | ||
| values: "134217728+0x390" |
| expr: | | ||
| ( | ||
| container_memory_working_set_bytes{container="kube-applier", namespace="kube-applier"} | ||
| / on(namespace, pod, container, cluster) group_left() | ||
| max by(namespace, pod, container, cluster) ( | ||
| kube_pod_container_resource_requests{container="kube-applier", namespace="kube-applier", resource="memory", job="kube-state-metrics"} | ||
| ) |
| # AROSLSRE-1071: Alert when kube-applier memory usage drifts significantly above its request | ||
| - alert: KubeApplierMemoryDrift |
| summary: 'kube-applier memory exceeds 1.5x its request on cluster {{ $labels.cluster }}.' | ||
| title: 'kube-applier memory exceeds 1.5x its request on cluster {{ $labels.cluster }}. pod:{{ $labels.pod }}' | ||
| } | ||
| expression: '(container_memory_working_set_bytes{container="kube-applier",namespace="kube-applier"} / on (namespace, pod, container, cluster) group_left () max by (namespace, pod, container, cluster) (kube_pod_container_resource_requests{container="kube-applier",job="kube-state-metrics",namespace="kube-applier",resource="memory"})) > 1.5' |
There was a problem hiding this comment.
This is a very useful alert we want to have on "any" pod we selectively run - backend, frontend, admin-api, cs, mgmt-agent, kube-applier, etc, etc, etc.
We also want the alerts to be container-agnostic for pods with many containers.
Please parameterize your annotations to be generic over the namespace/pod/container and cover "all" of our services from the first time we merge this, it should not be that much more work than this alert.
kube-applier has no proactive alerting for memory growth today. Add two PrometheusRule alerts so we can right-size the request before an OOM occurs:
Ref: AROSLSRE-1068
https://issues.redhat.com/browse/AROSLSRE-1068
What
Add two PrometheusRule alerts for kube-applier memory usage:
Both alerts include promtool unit tests and the generated bicep is updated.
Why
kube-applier currently has no proactive alerting for memory growth. Without these alerts, we can only react to OOM kills rather than right-sizing the request ahead of time. These alerts close the feedback loop so we know when to adjust the memory request in config.yaml.
Testing
observability/alerts/kubeApplierResources-prometheusRule_test.yaml)make alertspasses (generates bicep and runs promtool tests)Special notes for your reviewer
This is part of a larger effort (AROSLSRE-1068) that also includes setting evidence-based memory requests and pod priority for kube-applier (separate PRs).
PR Checklist