From 17d3d0c944c1621d2f8597ef13af96f71649e2f2 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss <erdnaxe@crans.org> Date: Sat, 8 Jun 2019 22:26:41 +0200 Subject: [PATCH] [prometheus] Adapt rules to stretch --- .../templates/prometheus/alert.rules.yml.j2 | 59 ++++++++----------- 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/roles/prometheus/templates/prometheus/alert.rules.yml.j2 b/roles/prometheus/templates/prometheus/alert.rules.yml.j2 index 18923c4f..8017fb55 100644 --- a/roles/prometheus/templates/prometheus/alert.rules.yml.j2 +++ b/roles/prometheus/templates/prometheus/alert.rules.yml.j2 @@ -1,5 +1,6 @@ # {{ ansible_managed }} {# As this is also Jinja2 it will conflict without a raw block #} +{# Depending of Prometheus Node exporter version, rules can change depending of version #} {% raw %} groups: - name: alert.rules @@ -17,8 +18,8 @@ groups: # Alert for out of memory - alert: OutOfMemory - expr: (node_memory_MemFree_bytes + node_memory_Cached_bytes + node_memory_Buffers_bytes) / node_memory_MemTotal_bytes * 100 < 10 - for: 30m + expr: ((node_memory_MemFree_bytes or node_memory_MemFree) + (node_memory_Cached_bytes or node_memory_Cached) + (node_memory_Buffers_bytes or node_memory_Buffers)) / (node_memory_MemTotal_bytes or node_memory_MemTotal) * 100 < 10 + for: 5m labels: severity: warning annotations: @@ -27,8 +28,8 @@ groups: # Alert for out of disk space - alert: OutOfDiskSpace - expr: node_filesystem_free_bytes{fstype="ext4"} / node_filesystem_size_bytes{fstype="ext4"} * 100 < 10 - for: 30m + expr: (node_filesystem_free_bytes{fstype="ext4"} or node_filesystem_free{fstype="ext4"}) / (node_filesystem_size_bytes{fstype="ext4"} or node_filesystem_size{fstype="ext4"}) * 100 < 10 + for: 5m labels: severity: warning annotations: @@ -38,7 +39,7 @@ groups: # Alert for out of inode space on disk - alert: OutOfInodes expr: node_filesystem_files_free{fstype="ext4"} / node_filesystem_files{fstype="ext4"} * 100 < 10 - for: 30m + for: 5m labels: severity: warning annotations: @@ -47,40 +48,30 @@ groups: # Alert for high CPU usage - alert: CpuLoad - expr: node_load15 / (count without (cpu, mode) (node_cpu_seconds_total{mode="system"})) > 2 - for: 30m + expr: node_load15 / (count without (cpu, mode) (node_cpu_seconds_total{mode="system"} or node_cpu{mode="system"})) > 2 + for: 5m labels: severity: warning annotations: summary: "Charge CPU élevée sur {{ $labels.instance }}" description: "La charge CPU (moyenne de 15mn) est élevée." - # Alert for any instance that has a median request latency >1s. - - alert: APIHighRequestLatency - expr: api_http_request_latencies_second{quantile="0.5"} > 1 - for: 10m - labels: - severity: warning - annotations: - summary: "Latence élevée sur {{ $labels.instance }}" - description: "{{ $labels.instance }} a un temps de réponse médian au dessus d'une seconde (actuellement : {{ $value }}s)." + # NTP (need NTP plugin in node) +# - alert: ntp_drifting +# expr: node_ntp_drift_seconds > 0.05 +# for: 3m +# labels: +# severity: critical +# annotations: +# summary: "Décalage NTP trop élevé sur {{ $labels.instance }}" +# description: "Le décalage NTP est trop élevé ({{ $value }} > 0.05)" - # NTP - - alert: ntp_drifting - expr: node_ntp_drift_seconds > 0.05 - for: 3m - labels: - severity: critical - annotations: - description: "Décalage NTP trop élevé sur {{ $labels.instance }}" - summary: "Le décalage NTP est trop élevé ({{ $value }} > 0.05)" - - - alert: ntp_drifting - expr: node_ntp_drift_seconds > 0.01 - for: 1m - labels: - severity: warning - annotations: - description: "Décalage NTP élevé sur {{ $labels.instance }}" - summary: "Le décalage NTP est élevé ({{ $value }} > 0.01)" +# - alert: ntp_drifting +# expr: node_ntp_drift_seconds > 0.01 +# for: 1m +# labels: +# severity: warning +# annotations: +# summary: "Décalage NTP élevé sur {{ $labels.instance }}" +# description: "Le décalage NTP est élevé ({{ $value }} > 0.01)" {% endraw %} -- GitLab