From d75dd689a66da00ca04f735ef7ae74b8c543d4e6 Mon Sep 17 00:00:00 2001
From: Alexandre Iooss <erdnaxe@crans.org>
Date: Tue, 23 Jul 2019 11:38:25 +0200
Subject: [PATCH] [prometheus] Group per instance

---
 .../templates/prometheus/alertmanager.yml.j2         |  2 +-
 roles/prometheus/tasks/main.yml                      | 12 ++++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/roles/prometheus-alertmanager/templates/prometheus/alertmanager.yml.j2 b/roles/prometheus-alertmanager/templates/prometheus/alertmanager.yml.j2
index 2e2a8af1..9adcd3cc 100644
--- a/roles/prometheus-alertmanager/templates/prometheus/alertmanager.yml.j2
+++ b/roles/prometheus-alertmanager/templates/prometheus/alertmanager.yml.j2
@@ -21,7 +21,7 @@ route:
   # The labels by which incoming alerts are grouped together. For example,
   # multiple alerts coming in for cluster=A and alertname=LatencyHigh would
   # be batched into a single group.
-  group_by: ['...']  # do not group for text chat
+  group_by: ['instance']  # group per instance
 
   # When a new group of alerts is created by an incoming alert, wait at
   # least 'group_wait' to send the initial notification.
diff --git a/roles/prometheus/tasks/main.yml b/roles/prometheus/tasks/main.yml
index 7b4e12d5..0e775a09 100644
--- a/roles/prometheus/tasks/main.yml
+++ b/roles/prometheus/tasks/main.yml
@@ -5,7 +5,6 @@
     name:
       - prometheus
       - prometheus-snmp-exporter
-      - snmp-mibs-downloader  # To generate SNMP configuration
   register: apt_result
   retries: 3
   until: apt_result is succeeded
@@ -25,16 +24,21 @@
     - alert.rules.yml
     - django.rules.yml
 
-# Doesn't work on Debian Stretch
 - name: Make Prometheus snmp-exporter listen on localhost only
-  when:
-    - ansible_lsb.codename == 'buster'
   lineinfile:
     path: /etc/default/prometheus-snmp-exporter
     regexp: '^ARGS='
     line: "ARGS=\"--web.listen-address=127.0.0.1:9116\""
   notify: Restart prometheus-snmp-exporter
 
+#- name: Configure Prometheus snmp-exporter
+#  template:
+#    src: "prometheus/snmp.yml.j2"
+#    dest: "/etc/prometheus/snmp.yml"
+#    mode: 0600
+#    owner: prometheus
+#  notify: Restart prometheus-snmp-exporter
+
 # We don't need to restart Prometheus when updating nodes
 - name: Configure Prometheus nodes
   copy:
-- 
GitLab