From 727d053dd4beb5fc97e4d255ffbd58bdd680f35d Mon Sep 17 00:00:00 2001
From: "Cesarini, Daniele" <daniele.cesarini@sky.uk>
Date: Tue, 14 Nov 2017 15:48:14 +0000
Subject: [PATCH] Fixing #751 K8SApiServerLatency always triggering

---
 assets/prometheus/rules/kube-apiserver.rules.yaml | 4 ++--
 manifests/grafana/grafana-dashboards.yaml         | 1 +
 manifests/prometheus/prometheus-k8s-rules.yaml    | 4 ++--
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/assets/prometheus/rules/kube-apiserver.rules.yaml b/assets/prometheus/rules/kube-apiserver.rules.yaml
index 55ebe025..50982b05 100644
--- a/assets/prometheus/rules/kube-apiserver.rules.yaml
+++ b/assets/prometheus/rules/kube-apiserver.rules.yaml
@@ -11,8 +11,8 @@ groups:
         disappeared from service discovery.
       summary: API server unreachable
   - alert: K8SApiServerLatency
-    expr: histogram_quantile(0.99, sum(apiserver_request_latencies_bucket{subresource!="log",verb!~"^(?:CONNECT|WATCHLIST|WATCH|PROXY)$"})
-      WITHOUT (instance, resource)) / 1e+06 > 1
+    expr: histogram_quantile(0.99, sum(rate(apiserver_request_latencies_bucket{subresource!="log",verb!~"^(?:CONNECT|WATCHLIST|WATCH|PROXY)$"}[10m]))
+       by (le)) / 1e+06 > 1
     for: 10m
     labels:
       severity: warning
diff --git a/manifests/grafana/grafana-dashboards.yaml b/manifests/grafana/grafana-dashboards.yaml
index aff751da..a55a8df5 100644
--- a/manifests/grafana/grafana-dashboards.yaml
+++ b/manifests/grafana/grafana-dashboards.yaml
@@ -6287,3 +6287,4 @@ data:
         "type": "prometheus",
         "url": "http://prometheus-k8s.monitoring.svc:9090"
     }
+---
diff --git a/manifests/prometheus/prometheus-k8s-rules.yaml b/manifests/prometheus/prometheus-k8s-rules.yaml
index d470c7bf..6be3ee49 100644
--- a/manifests/prometheus/prometheus-k8s-rules.yaml
+++ b/manifests/prometheus/prometheus-k8s-rules.yaml
@@ -227,8 +227,8 @@ data:
             disappeared from service discovery.
           summary: API server unreachable
       - alert: K8SApiServerLatency
-        expr: histogram_quantile(0.99, sum(rate(apiserver_request_latencies_bucket{subresource!="log",verb!~"^(?:CONNECT|WATCHLIST|WATCH|PROXY)$"}[10m])) 
-          by (le)) / 1e+06 > 1
+        expr: histogram_quantile(0.99, sum(rate(apiserver_request_latencies_bucket{subresource!="log",verb!~"^(?:CONNECT|WATCHLIST|WATCH|PROXY)$"}[10m]))
+           by (le)) / 1e+06 > 1
         for: 10m
         labels:
           severity: warning
-- 
GitLab