jsonnet/kube-prometheus: Prevent many-to-many matching

If there is more than one prometheus-operator pod, which happens briefly
when we delete the prometheus-operator pod, we can see the errors of
many-to-many matching, this whitelists the labels matching, and excluded
the pod.
This commit is contained in:
Lili Cosic
2019-08-16 15:16:13 +02:00
parent 2c7191d11c
commit 909f51b3bd

View File

@@ -10,7 +10,7 @@
message: 'The configuration of the instances of the Alertmanager cluster `{{$labels.service}}` are out of sync.', message: 'The configuration of the instances of the Alertmanager cluster `{{$labels.service}}` are out of sync.',
}, },
expr: ||| expr: |||
count_values("config_hash", alertmanager_config_hash{%(alertmanagerSelector)s}) BY (service) / ON(service) GROUP_LEFT() label_replace(prometheus_operator_spec_replicas{%(prometheusOperatorSelector)s,controller="alertmanager"}, "service", "alertmanager-$1", "name", "(.*)") != 1 count_values("config_hash", alertmanager_config_hash{%(alertmanagerSelector)s}) BY (service) / ON(service) GROUP_LEFT() label_replace(max(prometheus_operator_spec_replicas{%(prometheusOperatorSelector)s,controller="alertmanager"}) by (name, job, namespace, controller), "service", "alertmanager-$1", "name", "(.*)") != 1
||| % $._config, ||| % $._config,
'for': '5m', 'for': '5m',
labels: { labels: {
@@ -31,8 +31,8 @@
}, },
}, },
{ {
alert:'AlertmanagerMembersInconsistent', alert: 'AlertmanagerMembersInconsistent',
annotations:{ annotations: {
message: 'Alertmanager has not found all other members of the cluster.', message: 'Alertmanager has not found all other members of the cluster.',
}, },
expr: ||| expr: |||