Merge "[prometheus] Allow custom alert rules to be configured."

This commit is contained in:
Zuul 2018-08-30 11:57:11 +00:00 committed by Gerrit Code Review
commit 3f14a99f2a
4 changed files with 44 additions and 1 deletions

View File

@ -145,4 +145,5 @@
- inventory_hostname in groups[service.group]
- service.enabled | bool
- config_json.changed | bool
or prometheus_alertmanager_confs.changed | bool
or prometheus_container.changed | bool

View File

@ -24,6 +24,32 @@
notify:
- Restart {{ item.key }} container
- name: Find custom prometheus alert rules files
local_action:
module: find
path: "{{ node_custom_config }}/prometheus/"
pattern: "*.rules"
run_once: True
register: prometheus_alert_rules
when:
- enable_prometheus_alertmanager | bool
- name: Copying over custom prometheus alert rules files
vars:
service: "{{ prometheus_services['prometheus-server']}}"
copy:
src: "{{ item.path }}"
dest: "{{ node_config_directory }}/prometheus-server/{{ item.path | basename }}"
mode: "0660"
register: prometheus_confs
when:
- inventory_hostname in groups[service.group]
- service.enabled | bool and enable_prometheus_alertmanager | bool
- prometheus_alert_rules is defined and prometheus_alert_rules.files | length > 0
with_items: "{{ prometheus_alert_rules.files }}"
notify:
- Restart prometheus-server container
- name: Copying over prometheus config file
vars:
service: "{{ prometheus_services['prometheus-server']}}"
@ -47,7 +73,7 @@
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/prometheus-alertmanager/prometheus-alertmanager.yml"
register: prometheus_confs
register: prometheus_alertmanager_confs
when:
- inventory_hostname in groups[service.group]
- service.enabled | bool

View File

@ -7,6 +7,15 @@
"owner": "prometheus",
"perm": "0600"
}
{% if enable_prometheus_alertmanager %}
,{
"source": "{{ container_config_directory }}/*.rules",
"dest": "/etc/prometheus/",
"optional": true,
"owner": "prometheus",
"perm": "0600"
}
{% endif %}
],
"permissions": [
{

View File

@ -5,6 +5,13 @@ global:
external_labels:
monitor: 'kolla'
{% if prometheus_alert_rules is defined and prometheus_alert_rules.files | length > 0 %}
rule_files:
{% for rule in prometheus_alert_rules.files %}
- "/etc/prometheus/{{ rule.path | basename }}"
{% endfor %}
{% endif %}
scrape_configs:
- job_name: prometheus
static_configs: