2017-03-09 06:12:27 -05:00
|
|
|
{%- from "prometheus/map.jinja" import server with context %}
|
|
|
|
|
2017-04-11 06:17:08 -04:00
|
|
|
{%- set alerts = {} %}
|
|
|
|
{%- set recordings = {} %}
|
|
|
|
|
|
|
|
{%- for node_name, node_grains in salt['mine.get']('*', 'grains.items').iteritems() %}
|
|
|
|
{%- set server_grain = node_grains.get('prometheus', {}).get('server', {}) %}
|
2017-04-25 08:37:44 -04:00
|
|
|
{%- for recordingname, recording in server_grain.get('recording', {}).iteritems() %}
|
|
|
|
{%- do recordings.update({recordingname: recording}) %}
|
2017-04-11 06:17:08 -04:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endfor %}
|
|
|
|
|
2017-04-25 08:37:44 -04:00
|
|
|
{%- set recordings = salt['grains.filter_by']({'default': recordings}, merge=server.get('recording', {})) %}
|
2017-04-11 06:17:08 -04:00
|
|
|
|
2017-04-25 08:37:44 -04:00
|
|
|
{%- for recordingname, recording in recordings.iteritems() %}
|
|
|
|
{%- if recording.get('enabled', True) %}
|
|
|
|
{{ recordingname }} = {{ recording.query }}
|
2017-04-11 06:17:08 -04:00
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
|
|
|
|
|
|
|
{%- for node_name, node_grains in salt['mine.get']('*', 'grains.items').iteritems() %}
|
|
|
|
{%- set server_grain = node_grains.get('prometheus', {}).get('server', {}) %}
|
|
|
|
{%- for alertname, alert in server_grain.get('alert', {}).iteritems() %}
|
|
|
|
{%- do alerts.update({alertname: alert}) %}
|
|
|
|
{%- endfor %}
|
2017-03-29 06:39:52 -04:00
|
|
|
{%- endfor %}
|
|
|
|
|
2017-04-25 08:37:44 -04:00
|
|
|
{%- set alerts = salt['grains.filter_by']({'default': alerts}, merge=server.get('alert', {})) %}
|
|
|
|
|
2017-04-11 06:17:08 -04:00
|
|
|
{%- for alertname, alert in alerts.iteritems() %}
|
2017-04-25 08:37:44 -04:00
|
|
|
{%- if alert.get('enabled', True) %}
|
|
|
|
ALERT {{ alertname }}
|
|
|
|
IF {{ alert.if }}
|
2017-05-26 13:11:59 -04:00
|
|
|
{%- if alert.for is defined %}
|
|
|
|
FOR {{ alert.for }}{%- endif %}
|
2017-04-25 08:37:44 -04:00
|
|
|
{%- if alert.labels is defined %}
|
|
|
|
LABELS {
|
|
|
|
{%- for name, value in alert.labels.iteritems() %}
|
|
|
|
{{ name }} = "{{ value }}"{%- if not loop.last %},{%- endif %}
|
|
|
|
{%- endfor %}
|
|
|
|
}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if alert.annotations is defined %}
|
|
|
|
ANNOTATIONS {
|
|
|
|
{%- for name, value in alert.annotations.iteritems() %}
|
|
|
|
{{ name }} = "{{ value }}"{%- if not loop.last %},{%- endif %}
|
|
|
|
{%- endfor %}
|
|
|
|
}
|
|
|
|
{%- endif %}
|
2017-03-09 06:12:27 -05:00
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|