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

Implement multi-cluster alerts #2058

Merged
merged 1 commit into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions examples/prometheus-alerting-rules/alerts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ groups:
description: kube-state-metrics is experiencing errors at an elevated rate in list operations. This is likely causing it to not be able to expose metrics about Kubernetes objects correctly or at all.
summary: kube-state-metrics is experiencing errors in list operations.
expr: |
(sum(rate(kube_state_metrics_list_total{job="kube-state-metrics",result="error"}[5m]))
(sum(rate(kube_state_metrics_list_total{job="kube-state-metrics",result="error"}[5m])) by (cluster)
/
sum(rate(kube_state_metrics_list_total{job="kube-state-metrics"}[5m])))
sum(rate(kube_state_metrics_list_total{job="kube-state-metrics"}[5m])) by (cluster))
> 0.01
for: 15m
labels:
Expand All @@ -18,9 +18,9 @@ groups:
description: kube-state-metrics is experiencing errors at an elevated rate in watch operations. This is likely causing it to not be able to expose metrics about Kubernetes objects correctly or at all.
summary: kube-state-metrics is experiencing errors in watch operations.
expr: |
(sum(rate(kube_state_metrics_watch_total{job="kube-state-metrics",result="error"}[5m]))
(sum(rate(kube_state_metrics_watch_total{job="kube-state-metrics",result="error"}[5m])) by (cluster)
/
sum(rate(kube_state_metrics_watch_total{job="kube-state-metrics"}[5m])))
sum(rate(kube_state_metrics_watch_total{job="kube-state-metrics"}[5m])) by (cluster))
> 0.01
for: 15m
labels:
Expand All @@ -30,7 +30,7 @@ groups:
description: kube-state-metrics pods are running with different --total-shards configuration, some Kubernetes objects may be exposed multiple times or not exposed at all.
summary: kube-state-metrics sharding is misconfigured.
expr: |
stdvar (kube_state_metrics_total_shards{job="kube-state-metrics"}) != 0
stdvar (kube_state_metrics_total_shards{job="kube-state-metrics"}) by (cluster) != 0
for: 15m
labels:
severity: critical
Expand All @@ -39,9 +39,9 @@ groups:
description: kube-state-metrics shards are missing, some Kubernetes objects are not being exposed.
summary: kube-state-metrics shards are missing.
expr: |
2^max(kube_state_metrics_total_shards{job="kube-state-metrics"}) - 1
2^max(kube_state_metrics_total_shards{job="kube-state-metrics"}) by (cluster) - 1
-
sum( 2 ^ max by (shard_ordinal) (kube_state_metrics_shard_ordinal{job="kube-state-metrics"}) )
sum( 2 ^ max by (cluster, shard_ordinal) (kube_state_metrics_shard_ordinal{job="kube-state-metrics"}) ) by (cluster)
!= 0
for: 15m
labels:
Expand Down
14 changes: 7 additions & 7 deletions jsonnet/kube-state-metrics-mixin/alerts.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
{
alert: 'KubeStateMetricsListErrors',
expr: |||
(sum(rate(kube_state_metrics_list_total{%(kubeStateMetricsSelector)s,result="error"}[5m]))
(sum(rate(kube_state_metrics_list_total{%(kubeStateMetricsSelector)s,result="error"}[5m])) by (%(clusterLabel)s)
/
sum(rate(kube_state_metrics_list_total{%(kubeStateMetricsSelector)s}[5m])))
sum(rate(kube_state_metrics_list_total{%(kubeStateMetricsSelector)s}[5m])) by (%(clusterLabel)s))
> 0.01
||| % $._config,
'for': '15m',
Expand All @@ -24,9 +24,9 @@
{
alert: 'KubeStateMetricsWatchErrors',
expr: |||
(sum(rate(kube_state_metrics_watch_total{%(kubeStateMetricsSelector)s,result="error"}[5m]))
(sum(rate(kube_state_metrics_watch_total{%(kubeStateMetricsSelector)s,result="error"}[5m])) by (%(clusterLabel)s)
/
sum(rate(kube_state_metrics_watch_total{%(kubeStateMetricsSelector)s}[5m])))
sum(rate(kube_state_metrics_watch_total{%(kubeStateMetricsSelector)s}[5m])) by (%(clusterLabel)s))
> 0.01
||| % $._config,
'for': '15m',
Expand All @@ -42,7 +42,7 @@
alert: 'KubeStateMetricsShardingMismatch',
//
expr: |||
stdvar (kube_state_metrics_total_shards{%(kubeStateMetricsSelector)s}) != 0
stdvar (kube_state_metrics_total_shards{%(kubeStateMetricsSelector)s}) by (%(clusterLabel)s) != 0
||| % $._config,
'for': '15m',
labels: {
Expand All @@ -61,9 +61,9 @@
// A handy side effect of this computation is the result indicates what ordinals are missing.
// Eg. a result of "5" decimal, which translates to binary "101", means shards #0 and #2 are not available.
expr: |||
2^max(kube_state_metrics_total_shards{%(kubeStateMetricsSelector)s}) - 1
2^max(kube_state_metrics_total_shards{%(kubeStateMetricsSelector)s}) by (%(clusterLabel)s) - 1
-
sum( 2 ^ max by (shard_ordinal) (kube_state_metrics_shard_ordinal{%(kubeStateMetricsSelector)s}) )
sum( 2 ^ max by (%(clusterLabel)s, shard_ordinal) (kube_state_metrics_shard_ordinal{%(kubeStateMetricsSelector)s}) ) by (%(clusterLabel)s)
!= 0
||| % $._config,
'for': '15m',
Expand Down
1 change: 1 addition & 0 deletions jsonnet/kube-state-metrics-mixin/config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
_config+:: {
// Select the metrics coming from the kube state metrics.
kubeStateMetricsSelector: 'job="kube-state-metrics"',
clusterLabel: 'cluster',
},
}
Loading