From fda58119759931fff233587a659b2151c06a4ee8 Mon Sep 17 00:00:00 2001
From: Kyle Byerly <kyle.byerly@hpe.com>
Date: Wed, 28 Aug 2019 13:09:45 -0600
Subject: [PATCH] Add labels for namespace and service to TargetDown

---
 jsonnet/kube-prometheus/alerts/general.libsonnet | 2 +-
 manifests/prometheus-rules.yaml                  | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/jsonnet/kube-prometheus/alerts/general.libsonnet b/jsonnet/kube-prometheus/alerts/general.libsonnet
index 8802097e..4f949156 100644
--- a/jsonnet/kube-prometheus/alerts/general.libsonnet
+++ b/jsonnet/kube-prometheus/alerts/general.libsonnet
@@ -9,7 +9,7 @@
             annotations: {
               message: '{{ $value }}% of the {{ $labels.job }} targets are down.',
             },
-            expr: '100 * (count(up == 0) BY (job) / count(up) BY (job)) > 10',
+            expr: '100 * (count(up == 0) BY (job, namespace, service) / count(up) BY (job, namespace, service)) > 10',
             'for': '10m',
             labels: {
               severity: 'warning',
diff --git a/manifests/prometheus-rules.yaml b/manifests/prometheus-rules.yaml
index 65db451f..b90c8efb 100644
--- a/manifests/prometheus-rules.yaml
+++ b/manifests/prometheus-rules.yaml
@@ -1124,7 +1124,8 @@ spec:
     - alert: TargetDown
       annotations:
         message: '{{ $value }}% of the {{ $labels.job }} targets are down.'
-      expr: 100 * (count(up == 0) BY (job) / count(up) BY (job)) > 10
+      expr: 100 * (count(up == 0) BY (job, namespace, service) / count(up) BY (job,
+        namespace, service)) > 10
       for: 10m
       labels:
         severity: warning
-- 
GitLab