Allow to configure relabeling for alerts

Change-Id: I9fab8dc868c620330c5bdc8678d33a57c8256494
Prod-related: PROD-19595
This commit is contained in:
Dmitry Kalashnik 2018-04-24 14:02:15 +04:00
parent 93992a0742
commit 03a5b6d8eb

View file

@ -5,6 +5,31 @@ global:
{%- if server.get('config', {}).get('alertmanager') %} {%- if server.get('config', {}).get('alertmanager') %}
alerting: alerting:
{%- if server.get('config', {}).get('alert_relabel_configs') %}
alert_relabel_configs:
{%- for label in server.config.get('alert_relabel_configs', []) %}
- action: {{ label.get('action', 'replace') }}
{%- if label.get('source_labels') %}
{%- if label.source_labels is string %}
{%- set label_list = label.source_labels.split(',') %}
{%- elif label.source_labels is list %}
{%- set label_list = label.source_labels %}
{%- endif %}
{%- if label_list is defined %}
source_labels: {{ label_list }}
{%- endif %}
{%- endif %}
{%- if label.get('regex') %}
regex: "{{ label.regex }}"
{%- endif %}
{%- if label.get('target_label') %}
target_label: "{{ label.target_label }}"
{%- endif %}
{%- if label.get('replacement') %}
replacement: "{{ label.replacement }}"
{%- endif %}
{%- endfor %}
{%- endif %}
alertmanagers: alertmanagers:
{%- for name, alertmanager in server.config.alertmanager.iteritems() %} {%- for name, alertmanager in server.config.alertmanager.iteritems() %}
{%- if alertmanager.get('enabled', True) %} {%- if alertmanager.get('enabled', True) %}