Skip to content

feat: add memory drift and trend alerts for kube-applier#6011

Open
weherdh wants to merge 1 commit into
Azure:mainfrom
weherdh:aroslsre-1068-kube-applier-resources
Open

feat: add memory drift and trend alerts for kube-applier#6011
weherdh wants to merge 1 commit into
Azure:mainfrom
weherdh:aroslsre-1068-kube-applier-resources

Conversation

@weherdh

@weherdh weherdh commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

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.

Ref: AROSLSRE-1068

https://issues.redhat.com/browse/AROSLSRE-1068

What

Add two PrometheusRule alerts for kube-applier memory usage:

  • A drift alert that detects when actual memory exceeds 1.5x the configured request
  • A trend alert that uses predict_linear to warn when memory is projected to exceed 2x the request

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

  • promtool unit tests included (observability/alerts/kubeApplierResources-prometheusRule_test.yaml)
  • make alerts passes (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

  • PR is scoped to a single task (no mixed concerns)
  • Title follows Conventional Commits format
  • Summary explains the "Why" behind the change
  • Linked to relevant ticket/issue
  • Screenshots included (if graph/UI/metrics changes)
  • Self-reviewed the diff
  • CI/CD checks are passing (ignore Tide)
  • Draft PR used for WIP (if applicable)
  • Commit history is clean (rebased/squashed)
  • Tricky code blocks are commented
  • Specific reviewers tagged
  • All comment threads resolved before merge

Copilot AI review requested due to automatic review settings July 10, 2026 05:01
@openshift-ci

openshift-ci Bot commented Jul 10, 2026

Copy link
Copy Markdown

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 KubeApplierMemoryDrift and KubeApplierMemoryTrend PrometheusRule 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: []

Comment on lines +14 to +18
(
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
Comment on lines +33 to +37
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"}
Comment on lines +23 to +28
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
Comment on lines +43 to +49
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
Copilot AI review requested due to automatic review settings July 10, 2026 06:16
@weherdh weherdh force-pushed the aroslsre-1068-kube-applier-resources branch from c1a32a1 to 24fb306 Compare July 10, 2026 06:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

Comment on lines +47 to +49
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"
Comment on lines +74 to +76
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"
Comment on lines +13 to +19
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"}
)
Comment on lines +11 to +12
# 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'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants