|
24 | 24 | rules: [ |
25 | 25 | { |
26 | 26 | alert: 'KubeCPUOvercommit', |
| 27 | + labels: { |
| 28 | + severity: 'warning', |
| 29 | + }, |
| 30 | + annotations: { |
| 31 | + summary: 'Cluster has overcommitted CPU resource requests.', |
| 32 | + }, |
| 33 | + 'for': '10m', |
| 34 | + } + |
| 35 | + if $._config.showMultiCluster then { |
27 | 36 | expr: ||| |
28 | 37 | sum(namespace_cpu:kube_pod_container_resource_requests:sum{%(ignoringOverprovisionedWorkloadSelector)s}) by (%(clusterLabel)s) - (sum(kube_node_status_allocatable{resource="cpu"}) by (%(clusterLabel)s) - max(kube_node_status_allocatable{resource="cpu"}) by (%(clusterLabel)s)) > 0 |
29 | 38 | and |
30 | 39 | (sum(kube_node_status_allocatable{resource="cpu"}) by (%(clusterLabel)s) - max(kube_node_status_allocatable{resource="cpu"}) by (%(clusterLabel)s)) > 0 |
31 | 40 | ||| % $._config, |
| 41 | + annotations+: { |
| 42 | + description: 'Cluster {{ $labels.%(clusterLabel)s }} has overcommitted CPU resource requests for Pods by {{ $value }} CPU shares and cannot tolerate node failure.' % $._config, |
| 43 | + }, |
| 44 | + } else { |
| 45 | + expr: ||| |
| 46 | + sum(namespace_cpu:kube_pod_container_resource_requests:sum{%(ignoringOverprovisionedWorkloadSelector)s}) - (sum(kube_node_status_allocatable{resource="cpu"}) - max(kube_node_status_allocatable{resource="cpu"})) > 0 |
| 47 | + and |
| 48 | + (sum(kube_node_status_allocatable{resource="cpu"}) - max(kube_node_status_allocatable{resource="cpu"})) > 0 |
| 49 | + ||| % $._config, |
| 50 | + annotations+: { |
| 51 | + description: 'Cluster has overcommitted CPU resource requests for Pods by {{ $value }} CPU shares and cannot tolerate node failure.' % $._config, |
| 52 | + }, |
| 53 | + }, |
| 54 | + { |
| 55 | + alert: 'KubeMemoryOvercommit', |
32 | 56 | labels: { |
33 | 57 | severity: 'warning', |
34 | 58 | }, |
35 | 59 | annotations: { |
36 | | - description: 'Cluster {{ $labels.%(clusterLabel)s }} has overcommitted CPU resource requests for Pods by {{ $value }} CPU shares and cannot tolerate node failure.' % $._config, |
37 | | - summary: 'Cluster has overcommitted CPU resource requests.', |
| 60 | + summary: 'Cluster has overcommitted memory resource requests.', |
38 | 61 | }, |
39 | 62 | 'for': '10m', |
40 | | - }, |
41 | | - { |
42 | | - alert: 'KubeMemoryOvercommit', |
| 63 | + } + |
| 64 | + if $._config.showMultiCluster then { |
43 | 65 | expr: ||| |
44 | 66 | sum(namespace_memory:kube_pod_container_resource_requests:sum{%(ignoringOverprovisionedWorkloadSelector)s}) by (%(clusterLabel)s) - (sum(kube_node_status_allocatable{resource="memory"}) by (%(clusterLabel)s) - max(kube_node_status_allocatable{resource="memory"}) by (%(clusterLabel)s)) > 0 |
45 | 67 | and |
46 | 68 | (sum(kube_node_status_allocatable{resource="memory"}) by (%(clusterLabel)s) - max(kube_node_status_allocatable{resource="memory"}) by (%(clusterLabel)s)) > 0 |
47 | 69 | ||| % $._config, |
48 | | - labels: { |
49 | | - severity: 'warning', |
50 | | - }, |
51 | | - annotations: { |
| 70 | + annotations+: { |
52 | 71 | description: 'Cluster {{ $labels.%(clusterLabel)s }} has overcommitted memory resource requests for Pods by {{ $value | humanize }} bytes and cannot tolerate node failure.' % $._config, |
53 | | - summary: 'Cluster has overcommitted memory resource requests.', |
54 | 72 | }, |
55 | | - 'for': '10m', |
| 73 | + } else |
| 74 | + { |
| 75 | + expr: ||| |
| 76 | + sum(namespace_memory:kube_pod_container_resource_requests:sum{%(ignoringOverprovisionedWorkloadSelector)s}) - (sum(kube_node_status_allocatable{resource="memory"}) - max(kube_node_status_allocatable{resource="memory"})) > 0 |
| 77 | + and |
| 78 | + (sum(kube_node_status_allocatable{resource="memory"}) - max(kube_node_status_allocatable{resource="memory"})) > 0 |
| 79 | + ||| % $._config, |
| 80 | + annotations+: { |
| 81 | + description: 'Cluster has overcommitted memory resource requests for Pods by {{ $value | humanize }} bytes and cannot tolerate node failure.', |
| 82 | + }, |
56 | 83 | }, |
57 | 84 | { |
58 | 85 | alert: 'KubeCPUQuotaOvercommit', |
| 86 | + labels: { |
| 87 | + severity: 'warning', |
| 88 | + }, |
| 89 | + annotations: { |
| 90 | + summary: 'Cluster has overcommitted CPU resource requests.', |
| 91 | + }, |
| 92 | + 'for': '5m', |
| 93 | + } + |
| 94 | + if $._config.showMultiCluster then { |
59 | 95 | expr: ||| |
60 | 96 | sum(min without(resource) (kube_resourcequota{%(prefixedNamespaceSelector)s%(kubeStateMetricsSelector)s, type="hard", resource=~"(cpu|requests.cpu)"})) by (%(clusterLabel)s) |
61 | 97 | / |
62 | 98 | sum(kube_node_status_allocatable{resource="cpu", %(kubeStateMetricsSelector)s}) by (%(clusterLabel)s) |
63 | 99 | > %(namespaceOvercommitFactor)s |
64 | 100 | ||| % $._config, |
65 | | - labels: { |
66 | | - severity: 'warning', |
67 | | - }, |
68 | | - annotations: { |
| 101 | + annotations+: { |
69 | 102 | description: 'Cluster {{ $labels.%(clusterLabel)s }} has overcommitted CPU resource requests for Namespaces.' % $._config, |
70 | | - summary: 'Cluster has overcommitted CPU resource requests.', |
71 | 103 | }, |
72 | | - 'for': '5m', |
73 | | - }, |
| 104 | + } else |
74 | 105 | { |
75 | | - alert: 'KubeMemoryQuotaOvercommit', |
76 | 106 | expr: ||| |
77 | | - sum(min without(resource) (kube_resourcequota{%(prefixedNamespaceSelector)s%(kubeStateMetricsSelector)s, type="hard", resource=~"(memory|requests.memory)"})) by (%(clusterLabel)s) |
| 107 | + sum(min without(resource) (kube_resourcequota{%(prefixedNamespaceSelector)s%(kubeStateMetricsSelector)s, type="hard", resource=~"(cpu|requests.cpu)"})) |
78 | 108 | / |
79 | | - sum(kube_node_status_allocatable{resource="memory", %(kubeStateMetricsSelector)s}) by (%(clusterLabel)s) |
| 109 | + sum(kube_node_status_allocatable{resource="cpu", %(kubeStateMetricsSelector)s}) |
80 | 110 | > %(namespaceOvercommitFactor)s |
81 | 111 | ||| % $._config, |
| 112 | + annotations+: { |
| 113 | + description: 'Cluster has overcommitted CPU resource requests for Namespaces.', |
| 114 | + }, |
| 115 | + }, |
| 116 | + { |
| 117 | + alert: 'KubeMemoryQuotaOvercommit', |
82 | 118 | labels: { |
83 | 119 | severity: 'warning', |
84 | 120 | }, |
85 | 121 | annotations: { |
86 | | - description: 'Cluster {{ $labels.%(clusterLabel)s }} has overcommitted memory resource requests for Namespaces.' % $._config, |
87 | 122 | summary: 'Cluster has overcommitted memory resource requests.', |
88 | 123 | }, |
89 | 124 | 'for': '5m', |
| 125 | + } + |
| 126 | + if $._config.showMultiCluster then { |
| 127 | + expr: ||| |
| 128 | + sum(min without(resource) (kube_resourcequota{%(prefixedNamespaceSelector)s%(kubeStateMetricsSelector)s, type="hard", resource=~"(memory|requests.memory)"})) by (%(clusterLabel)s) |
| 129 | + / |
| 130 | + sum(kube_node_status_allocatable{resource="memory", %(kubeStateMetricsSelector)s}) by (%(clusterLabel)s) |
| 131 | + > %(namespaceOvercommitFactor)s |
| 132 | + ||| % $._config, |
| 133 | + annotations+: { |
| 134 | + description: 'Cluster {{ $labels.%(clusterLabel)s }} has overcommitted memory resource requests for Namespaces.' % $._config, |
| 135 | + }, |
| 136 | + } else |
| 137 | + { |
| 138 | + expr: ||| |
| 139 | + sum(min without(resource) (kube_resourcequota{%(prefixedNamespaceSelector)s%(kubeStateMetricsSelector)s, type="hard", resource=~"(memory|requests.memory)"})) |
| 140 | + / |
| 141 | + sum(kube_node_status_allocatable{resource="memory", %(kubeStateMetricsSelector)s}) |
| 142 | + > %(namespaceOvercommitFactor)s |
| 143 | + ||| % $._config, |
| 144 | + annotations+: { |
| 145 | + description: 'Cluster has overcommitted memory resource requests for Namespaces.', |
| 146 | + }, |
90 | 147 | }, |
91 | 148 | { |
92 | 149 | alert: 'KubeQuotaAlmostFull', |
|
0 commit comments