-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_metrics_alerts.yml
78 lines (69 loc) · 2.63 KB
/
setup_metrics_alerts.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
- hosts: localhost
name: "Creates or Update the AxonOps metrics alerts"
become: false
connection: local
gather_facts: false
pre_tasks:
- name: Get the Org name
tags: always
ansible.builtin.set_fact:
org: "{{ lookup('env', 'AXONOPS_ORG') }}"
when: org is not defined
- name: Get the cluster name
tags: always
ansible.builtin.set_fact:
cluster: "{{ lookup('env', 'AXONOPS_CLUSTER') }}"
when: cluster is not defined
- name: Fail if no org
ansible.builtin.assert:
that:
- org is defined
- org | length > 1
- cluster is defined
- name: Initialize axonops_alert_rules
tags: always
ansible.builtin.set_fact:
axonops_alert_rules: "{{ axonops_alert_rules | default([]) }}"
- name: Load organization-wide alert rules
tags: always
ansible.builtin.set_fact:
axonops_alert_rules: "{{ axonops_alert_rules + (lookup('file', item) | from_yaml).axonops_alert_rules }}"
with_fileglob:
- "config/{{ org }}/metric_alert_rules.yml"
- name: Load cluster-specific alert rules
tags: always
ansible.builtin.set_fact:
axonops_alert_rules: "{{ axonops_alert_rules + (lookup('file', item) | from_yaml).axonops_alert_rules }}"
with_fileglob:
- "config/{{ org }}/{{ cluster }}/metric_alert_rules.yml"
- name: Install alerts on {{ org }}/{{ cluster }}
axonops.configuration.alert_rule:
org: "{{ org }}"
cluster: "{{ cluster }}"
dashboard: "{{ item.dashboard }}"
chart: "{{ item.chart }}"
operator: "{{ item.operator }}"
warning_value: "{{ item.warning_value }}"
critical_value: "{{ item.critical_value }}"
duration: "{{ item.duration }}"
present: "{{ item.present|default(true) }}"
description: "{{ item.description|default() }}"
name: "{{ item.name|default() }}"
scope: "{{ item.scope|default([]) }}"
group_by: "{{ item.group_by|default([]) }}"
routing: "{{ item.routing|default(omit) }}"
percentile: "{{ item.percentile|default([]) }}"
consistency: "{{ item.consistency|default([]) }}"
metric: "{{ item.metric|default(omit) }}"
keyspace: "{{ item.keyspace|default([]) }}"
dc: "{{ item.dc|default([]) }}"
rack: "{{ item.rack|default([]) }}"
host_id: "{{ item.host_id|default([]) }}"
loop: "{{ axonops_alert_rules }}"
no_log: "{{ false if enable_logging is defined and enable_logging else true }}"
tags:
- axonops_alert_rule
- alert_rule
- alert
- rule
# code: language=ansible