Files
bab-backend-ansible/rulebooks/alertmanager_listener.yml

49 lines
1.7 KiB
YAML

---
- name: Listen for Alertmanager events
hosts: all
sources:
- name: Ansible Alertmanager listener
ansible.eda.alertmanager:
port: 9101
host: 0.0.0.0
rules:
- name: Resolve Disk Usage
condition:
all:
- event.alert.labels.org == "OYS" and event.alert.status == "firing"
and event.alert.labels.alertname == "root filesystem over 80% full"
actions:
- run_job_template:
name: Demo - Clean Log Directory
organization: OYS
job_args:
extra_vars:
alertmanager_annotations: "{{ event.alert.annotations }}"
alertmanager_generator_url: "{{ event.alert.generatorURL }}"
event_mountpoint: "{{ event.alert.labels.mountpoint }}"
alertmanager_instance: "{{ event.alert.labels.instance }}"
- name: Investigate High CPU
condition:
all:
- event.alert.labels.org == "OYS" and event.alert.status == "firing"
and event.alert.labels.alertname == "ProcessCPUHog"
actions:
- print_event:
pretty: true
- run_job_template:
name: Demo - Investigate High CPU
organization: OYS
job_args:
extra_vars:
alertmanager_annotations: "{{ event.alert.annotations }}"
alertmanager_generator_url: "{{ event.alert.generatorURL }}"
event_severity: "{{ event.alert.labels.severity }}"
alertmanager_instance: "{{ event.alert.labels.instance }}"
- name: Test Contact Point
condition: event.alert.labels.alertname == "TestAlert" and event.alert.labels.org == "OYS"
actions:
- print_event:
pretty: true