From fb101d4152c34cd33ffc33fafc31b569a4ce6dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Tue, 29 Mar 2022 18:53:15 +0200 Subject: [PATCH] improve format of display_name and state_message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- defaults/main.yml | 15 ++++++++++++++- templates/alertmanager.yml.j2 | 4 +++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index c9ae4c3..22c024f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -50,7 +50,20 @@ alertmanager_victorops_api_key: ~ alertmanager_victorops_service_url: ~ alertmanager_victorops_routing_key: ~ alertmanager_victorops_message_type: 'CRITICAL' # CRITICAL, WARNING, INFO -alertmanager_victorops_state_message: '{% raw %}Alert: {{ .CommonLabels.alertname }}. Summary:{{ .CommonAnnotations.summary }}. RawData: {{ .CommonLabels }}{% endraw %}' +alertmanager_victorops_monitoring_tool: 'metrics' +alertmanager_victorops_state_message: | + {% raw %} + {{ .CommonLabels.alertname }}: + {{ .CommonAnnotations.summary }}. + Common: {{ .CommonLabels }} + Group: {{ .GroupLabels }} + {% endraw %} + +alertmanager_victorops_display_name: >- + {% raw %} + {{ .CommonLabels.datacenter }}.{{ .GroupLabels.fleet }} + ({{ .GroupLabels.alertname }}) + {% endraw %} # For discovery of prometheus master nodes consul_catalog_url: 'http://localhost:8500/v1/catalog' diff --git a/templates/alertmanager.yml.j2 b/templates/alertmanager.yml.j2 index 9f49822..358e38e 100644 --- a/templates/alertmanager.yml.j2 +++ b/templates/alertmanager.yml.j2 @@ -35,5 +35,7 @@ receivers: - name: 'victorops-alerts' victorops_configs: - routing_key: '{{ alertmanager_victorops_routing_key | mandatory }}' - state_message: '{{ alertmanager_victorops_state_message | mandatory }}' message_type: '{{ alertmanager_victorops_message_type | mandatory }}' + monitoring_tool: '{{ alertmanager_victorops_monitoring_tool | mandatory }}' + entity_display_name: '{{ alertmanager_victorops_display_name | mandatory | trim }}' + state_message: '{{ alertmanager_victorops_state_message | mandatory | trim }}'