Merge "[prometheus] Allow custom alert rules to be configured."
This commit is contained in:
commit
3f14a99f2a
@ -145,4 +145,5 @@
|
|||||||
- inventory_hostname in groups[service.group]
|
- inventory_hostname in groups[service.group]
|
||||||
- service.enabled | bool
|
- service.enabled | bool
|
||||||
- config_json.changed | bool
|
- config_json.changed | bool
|
||||||
|
or prometheus_alertmanager_confs.changed | bool
|
||||||
or prometheus_container.changed | bool
|
or prometheus_container.changed | bool
|
||||||
|
@ -24,6 +24,32 @@
|
|||||||
notify:
|
notify:
|
||||||
- Restart {{ item.key }} container
|
- 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
|
- name: Copying over prometheus config file
|
||||||
vars:
|
vars:
|
||||||
service: "{{ prometheus_services['prometheus-server']}}"
|
service: "{{ prometheus_services['prometheus-server']}}"
|
||||||
@ -47,7 +73,7 @@
|
|||||||
template:
|
template:
|
||||||
src: "{{ item }}"
|
src: "{{ item }}"
|
||||||
dest: "{{ node_config_directory }}/prometheus-alertmanager/prometheus-alertmanager.yml"
|
dest: "{{ node_config_directory }}/prometheus-alertmanager/prometheus-alertmanager.yml"
|
||||||
register: prometheus_confs
|
register: prometheus_alertmanager_confs
|
||||||
when:
|
when:
|
||||||
- inventory_hostname in groups[service.group]
|
- inventory_hostname in groups[service.group]
|
||||||
- service.enabled | bool
|
- service.enabled | bool
|
||||||
|
@ -7,6 +7,15 @@
|
|||||||
"owner": "prometheus",
|
"owner": "prometheus",
|
||||||
"perm": "0600"
|
"perm": "0600"
|
||||||
}
|
}
|
||||||
|
{% if enable_prometheus_alertmanager %}
|
||||||
|
,{
|
||||||
|
"source": "{{ container_config_directory }}/*.rules",
|
||||||
|
"dest": "/etc/prometheus/",
|
||||||
|
"optional": true,
|
||||||
|
"owner": "prometheus",
|
||||||
|
"perm": "0600"
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
],
|
],
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,13 @@ global:
|
|||||||
external_labels:
|
external_labels:
|
||||||
monitor: 'kolla'
|
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:
|
scrape_configs:
|
||||||
- job_name: prometheus
|
- job_name: prometheus
|
||||||
static_configs:
|
static_configs:
|
||||||
|
Loading…
Reference in New Issue
Block a user