Skip to content

Commit

Permalink
Merge pull request #2058 from jkroepke/multi-cluster
Browse files Browse the repository at this point in the history
Implement multi-cluster alerts
  • Loading branch information
k8s-ci-robot authored May 12, 2023
2 parents 5f31736 + 7c7a9ce commit 3b95dd1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
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',
},
}

0 comments on commit 3b95dd1

Please sign in to comment.