Allow to configure relabeling for alerts
Change-Id: I9fab8dc868c620330c5bdc8678d33a57c8256494
Prod-related: PROD-19595
diff --git a/prometheus/files/server/prometheus.yml b/prometheus/files/server/prometheus.yml
index 3bb85f7..53c7b0c 100644
--- a/prometheus/files/server/prometheus.yml
+++ b/prometheus/files/server/prometheus.yml
@@ -5,6 +5,31 @@
{%- if server.get('config', {}).get('alertmanager') %}
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:
{%- for name, alertmanager in server.config.alertmanager.iteritems() %}
{%- if alertmanager.get('enabled', True) %}