Support for custom add custom labels from reclass
This change will enable possibility to add custom labels to alerts. This can be used ex. to provite routing key for pushkin (notification service) If given key already exists in alert, it will NOT be overriden. prometheus: server: config: alert: labels_add: route: 'mail,skype' Change-Id: I0b21d8a9695e8a15d0d6b80e6ddd0476682c80c2
This commit is contained in:
parent
9b3d774430
commit
b845f3fc69
1 changed files with 11 additions and 1 deletions
|
@ -33,13 +33,23 @@
|
|||
IF {{ alert.if }}
|
||||
{%- if alert.for is defined %}
|
||||
FOR {{ alert.for }}{%- endif %}
|
||||
{%- if alert.labels is defined %}
|
||||
{#- Handle labels #}
|
||||
{%- if alert.labels is not defined %}
|
||||
{%- do alert.update({'labels': {}}) %}
|
||||
{%- endif %}
|
||||
{%- for label_name, label_value in server.get('config', {}).get('alert', {}).get('labels_add', {}).iteritems() %}
|
||||
{%- if label_name not in alert.labels %}
|
||||
{%- do alert.labels.update({label_name: label_value}) %}
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
{%- if alert.labels %}
|
||||
LABELS {
|
||||
{%- for name, value in alert.labels.iteritems() %}
|
||||
{{ name }} = "{{ value }}"{%- if not loop.last %},{%- endif %}
|
||||
{%- endfor %}
|
||||
}
|
||||
{%- endif %}
|
||||
{#- Handle annotations #}
|
||||
{%- if alert.annotations is defined %}
|
||||
ANNOTATIONS {
|
||||
{%- for name, value in alert.annotations.iteritems() %}
|
||||
|
|
Loading…
Reference in a new issue