From 0896c024dcb6a0150b1613b24b924f07b953624b Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Tue, 22 Sep 2020 14:30:18 +0100
Subject: [PATCH] Fix the host_reachable metric

Without the 'bool' operator qualifier, it would only generate
values for reachable hosts, invalidating the alert logic.
---
 roles/prometheus/templates/rules/rules_base.conf.yml | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/roles/prometheus/templates/rules/rules_base.conf.yml b/roles/prometheus/templates/rules/rules_base.conf.yml
index 7f08c3b7..cd3b4ab3 100644
--- a/roles/prometheus/templates/rules/rules_base.conf.yml
+++ b/roles/prometheus/templates/rules/rules_base.conf.yml
@@ -27,6 +27,7 @@ groups:
 
       # Special metric for the ping probe. The label_replace() sets
       # the host to the value of the target label (instead of the host
-      # running the prober).
+      # running the prober). The 'bool' qualifier makes the greater-than
+      # operation not act as a filter.
       - record: host_reachable
-        expr: label_replace(target:probe_success:ratio{probe="ping"} > 0.6, "host", "$1", "target", "(.*)")
+        expr: label_replace(target:probe_success:ratio{probe="ping"} > bool 0.6, "host", "$1", "target", "(.*)")
-- 
GitLab