|
24 | 24 | rules: [ |
25 | 25 | { |
26 | 26 | alert: 'KubeCPUOvercommit', |
27 | | - expr: ||| |
28 | | - 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 |
29 | | - and |
30 | | - (sum(kube_node_status_allocatable{resource="cpu"}) - max(kube_node_status_allocatable{resource="cpu"})) > 0 |
31 | | - ||| % $._config, |
32 | 27 | labels: { |
33 | 28 | severity: 'warning', |
34 | 29 | }, |
35 | 30 | annotations: { |
36 | | - description: 'Cluster has overcommitted CPU resource requests for Pods by {{ $value }} CPU shares and cannot tolerate node failure.', |
37 | 31 | summary: 'Cluster has overcommitted CPU resource requests.', |
38 | 32 | }, |
39 | 33 | 'for': '10m', |
40 | | - }, |
41 | | - { |
42 | | - alert: 'KubeMemoryOvercommit', |
| 34 | + } + |
| 35 | + if $._config.showMultiCluster then { |
| 36 | + expr: ||| |
| 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 |
| 38 | + and |
| 39 | + (sum(kube_node_status_allocatable{resource="cpu"}) by (%(clusterLabel)s) - max(kube_node_status_allocatable{resource="cpu"}) by (%(clusterLabel)s)) > 0 |
| 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 { |
43 | 45 | expr: ||| |
44 | | - 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 |
| 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 |
45 | 47 | and |
46 | | - (sum(kube_node_status_allocatable{resource="memory"}) - max(kube_node_status_allocatable{resource="memory"})) > 0 |
| 48 | + (sum(kube_node_status_allocatable{resource="cpu"}) - max(kube_node_status_allocatable{resource="cpu"})) > 0 |
47 | 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', |
48 | 56 | labels: { |
49 | 57 | severity: 'warning', |
50 | 58 | }, |
51 | 59 | annotations: { |
52 | | - description: 'Cluster has overcommitted memory resource requests for Pods by {{ $value | humanize }} bytes and cannot tolerate node failure.', |
53 | 60 | summary: 'Cluster has overcommitted memory resource requests.', |
54 | 61 | }, |
55 | 62 | 'for': '10m', |
56 | | - }, |
57 | | - { |
58 | | - alert: 'KubeCPUQuotaOvercommit', |
| 63 | + } + |
| 64 | + if $._config.showMultiCluster then { |
59 | 65 | expr: ||| |
60 | | - sum(min without(resource) (kube_resourcequota{%(prefixedNamespaceSelector)s%(kubeStateMetricsSelector)s, type="hard", resource=~"(cpu|requests.cpu)"})) |
61 | | - / |
62 | | - sum(kube_node_status_allocatable{resource="cpu", %(kubeStateMetricsSelector)s}) |
63 | | - > %(namespaceOvercommitFactor)s |
| 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 |
| 67 | + and |
| 68 | + (sum(kube_node_status_allocatable{resource="memory"}) by (%(clusterLabel)s) - max(kube_node_status_allocatable{resource="memory"}) by (%(clusterLabel)s)) > 0 |
64 | 69 | ||| % $._config, |
| 70 | + annotations+: { |
| 71 | + description: 'Cluster {{ $labels.%(clusterLabel)s }} has overcommitted memory resource requests for Pods by {{ $value | humanize }} bytes and cannot tolerate node failure.' % $._config, |
| 72 | + }, |
| 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 | + }, |
| 83 | + }, |
| 84 | + { |
| 85 | + alert: 'KubeCPUQuotaOvercommit', |
65 | 86 | labels: { |
66 | 87 | severity: 'warning', |
67 | 88 | }, |
68 | 89 | annotations: { |
69 | | - description: 'Cluster has overcommitted CPU resource requests for Namespaces.', |
70 | 90 | summary: 'Cluster has overcommitted CPU resource requests.', |
71 | 91 | }, |
72 | 92 | 'for': '5m', |
73 | | - }, |
74 | | - { |
75 | | - alert: 'KubeMemoryQuotaOvercommit', |
| 93 | + } + |
| 94 | + if $._config.showMultiCluster then { |
76 | 95 | expr: ||| |
77 | | - sum(min without(resource) (kube_resourcequota{%(prefixedNamespaceSelector)s%(kubeStateMetricsSelector)s, type="hard", resource=~"(memory|requests.memory)"})) |
| 96 | + sum(min without(resource) (kube_resourcequota{%(prefixedNamespaceSelector)s%(kubeStateMetricsSelector)s, type="hard", resource=~"(cpu|requests.cpu)"})) by (%(clusterLabel)s) |
78 | 97 | / |
79 | | - sum(kube_node_status_allocatable{resource="memory", %(kubeStateMetricsSelector)s}) |
| 98 | + sum(kube_node_status_allocatable{resource="cpu", %(kubeStateMetricsSelector)s}) by (%(clusterLabel)s) |
80 | 99 | > %(namespaceOvercommitFactor)s |
81 | 100 | ||| % $._config, |
| 101 | + annotations+: { |
| 102 | + description: 'Cluster {{ $labels.%(clusterLabel)s }} has overcommitted CPU resource requests for Namespaces.' % $._config, |
| 103 | + }, |
| 104 | + } else |
| 105 | + { |
| 106 | + expr: ||| |
| 107 | + sum(min without(resource) (kube_resourcequota{%(prefixedNamespaceSelector)s%(kubeStateMetricsSelector)s, type="hard", resource=~"(cpu|requests.cpu)"})) |
| 108 | + / |
| 109 | + sum(kube_node_status_allocatable{resource="cpu", %(kubeStateMetricsSelector)s}) |
| 110 | + > %(namespaceOvercommitFactor)s |
| 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 has overcommitted memory resource requests for Namespaces.', |
87 | 122 | summary: 'Cluster has overcommitted memory resource requests.', |
88 | 123 | }, |
89 | 124 | 'for': '5m', |
90 | | - }, |
| 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 | + }, |
| 147 | + }, |
91 | 148 | { |
92 | 149 | alert: 'KubeQuotaAlmostFull', |
93 | 150 | expr: ||| |
|
0 commit comments