Add support for custom alert notification templates

Change-Id: I9e4e1287ea69960ae3b13734acc3eb0b087a8d86
This commit is contained in:
Piotr Parczewski 2022-05-17 14:55:50 +02:00
parent 5645a4c008
commit 77e811e25c
4 changed files with 40 additions and 1 deletions

View File

@ -115,6 +115,32 @@
notify:
- Restart prometheus-alertmanager container
- name: Find custom Alertmanager alert notification templates
find:
path: "{{ node_custom_config }}/prometheus/"
pattern: "*.tmpl"
run_once: True
delegate_to: localhost
register: alertmanager_notification_templates
when:
- enable_prometheus_alertmanager | bool
- name: Copying over custom Alertmanager alert notification templates
become: true
vars:
service: "{{ prometheus_services['prometheus-alertmanager'] }}"
copy:
src: "{{ item.path }}"
dest: "{{ node_config_directory }}/prometheus-alertmanager/{{ item.path | basename }}"
mode: 0660
when:
- inventory_hostname in groups[service.group]
- service.enabled | bool
- alertmanager_notification_templates is defined and alertmanager_notification_templates.files | length > 0
with_items: "{{ alertmanager_notification_templates.files }}"
notify:
- Restart prometheus-alertmanager container
- name: Copying over my.cnf for mysqld_exporter
become: true
vars:

View File

@ -6,6 +6,13 @@
"dest": "/etc/prometheus/alertmanager.yml",
"owner": "prometheus",
"perm": "0600"
},
{
"source": "{{ container_config_directory }}/*.tmpl",
"dest": "/etc/prometheus/",
"optional": true,
"owner": "prometheus",
"perm": "0600"
}
],
"permissions": [

View File

@ -17,4 +17,5 @@ receivers:
username: '{{ keystone_admin_user }}'
password: '{{ keystone_admin_password }}'
{% endif %}
templates: []
templates:
- '/etc/prometheus/*.tmpl'

View File

@ -0,0 +1,5 @@
---
features:
- |
Adds possibility for inlcuding custom alert notification templates with
Prometheus Alertmanager.