Skip to content
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

Create alert for OOMKill events inside containers #822

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions alerts/resource_alerts.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// See https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md#how-can-i-configure-overprovisioning-with-cluster-autoscaler
// for more details.
ignoringOverprovisionedWorkloadSelector: '',
// Maximum rate of OOMKiller events that is considered normal for any single container
maxOOMKillRate: 0,
},

prometheusAlerts+:: {
Expand Down Expand Up @@ -213,6 +215,21 @@
summary: 'Processes experience elevated CPU throttling.',
},
},
{
alert: 'KubeContainerOOMEvents',
expr: |||
sum by (namespace, pod, container, %(clusterLabel)s)
(rate(container_oom_events_total[5m])) > %(maxOOMKillRate)s
||| % $._config,
labels: {
severity: 'warning',
},
'for': '5m',
annotations: {
description: 'Processes are being killed by the Out Of Memory (OOM) Killer inside the "{{ $labels.container}}" container in pod {{ $labels.namespace }}/{{ $labels.pod }}.',
summary: 'Processes are being OOMKilled',
},
},
],
},
],
Expand Down
24 changes: 23 additions & 1 deletion tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ tests:
runbook_url: "https://github.com/kubernetes-monitoring/kubernetes-mixin/tree/master/runbook.md#alert-name-kubepodcrashlooping"
summary: "Pod is crash looping."
- eval_time: 20m
alertname: KubePodCrashLooping # alert fired for a period of 5 minutes after resolution because the alert looks back at the last 5 minutes of data and the range vector doesn't take stale samples into account
alertname: KubePodCrashLooping # alert fired for a period of 5 minutes after resolution because the alert looks back at the last 5 minutes of data and the range vector doesn't take stale samples into account
exp_alerts:
- exp_labels:
severity: "warning"
Expand Down Expand Up @@ -1214,3 +1214,25 @@ tests:
description: 'Cluster has overcommitted memory resource requests for Namespaces.'
runbook_url: "https://github.com/kubernetes-monitoring/kubernetes-mixin/tree/master/runbook.md#alert-name-kubememoryquotaovercommit"
summary: "Cluster has overcommitted memory resource requests."

- interval: 1m
input_series:
- series: 'container_oom_events_total{container="dbserver", namespace="default", pod="dbserver-128fnk319a-alq1x"}'
values: '0 0 0 0 0 0 0'
- series: 'container_oom_events_total{container="webserver", namespace="default", pod="webserver-69755ddb67-dn2v5"}'
values: '0 2 2 4 4 4 4'
alert_rule_test:
- eval_time: 5m
alertname: KubeContainerOOMEvents
- eval_time: 6m
alertname: KubeContainerOOMEvents
exp_alerts:
- exp_labels:
container: webserver
namespace: default
pod: webserver-69755ddb67-dn2v5
severity: warning
exp_annotations:
summary: Processes are being OOMKilled
description: Processes are being killed by the Out Of Memory (OOM) Killer inside the "webserver" container in pod default/webserver-69755ddb67-dn2v5.
runbook_url: https://github.com/kubernetes-monitoring/kubernetes-mixin/tree/master/runbook.md#alert-name-kubecontaineroomevents