From 00dd58eacecf2efc75e3d3939313e84e371df8fe Mon Sep 17 00:00:00 2001 From: Per Lundberg Date: Wed, 25 Nov 2020 16:06:05 +0200 Subject: [PATCH] Fix Redis missing master query The previous approach fails because of the "missing data" semantics in Prometheus. If the Redis server is down, PromQL will typically return "no data" instead of 0 for a `count()`; this is by design in Prometheus. This suggestion as given by @slovdahl works around this by returning an vector with a single `0` entry in this case, making the query work as intended. --- _data/rules.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/rules.yml b/_data/rules.yml index 3fe8f8a..430c2f1 100644 --- a/_data/rules.yml +++ b/_data/rules.yml @@ -520,7 +520,7 @@ groups: severity: critical - name: Redis missing master description: Redis cluster has no node marked as master. - query: 'count(redis_instance_info{role="master"}) == 0' + query: 'count(redis_instance_info{role="master"}) or vector(0) < 1' severity: critical - name: Redis too many masters description: Redis cluster has too many nodes marked as master.