Merge "Support for custom add custom labels from reclass"

This commit is contained in:
Bartosz Kupidura 2017-06-27 10:28:00 +00:00 committed by Gerrit Code Review
commit a5123c928a

View file

@ -33,13 +33,23 @@
IF {{ alert.if }} IF {{ alert.if }}
{%- if alert.for is defined %} {%- if alert.for is defined %}
FOR {{ alert.for }}{%- endif %} 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 { LABELS {
{%- for name, value in alert.labels.iteritems() %} {%- for name, value in alert.labels.iteritems() %}
{{ name }} = "{{ value }}"{%- if not loop.last %},{%- endif %} {{ name }} = "{{ value }}"{%- if not loop.last %},{%- endif %}
{%- endfor %} {%- endfor %}
} }
{%- endif %} {%- endif %}
{#- Handle annotations #}
{%- if alert.annotations is defined %} {%- if alert.annotations is defined %}
ANNOTATIONS { ANNOTATIONS {
{%- for name, value in alert.annotations.iteritems() %} {%- for name, value in alert.annotations.iteritems() %}