-
Notifications
You must be signed in to change notification settings - Fork 0
/
prometheus.yml
426 lines (397 loc) · 11.9 KB
/
prometheus.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
---
# Nginx (Prometheus SSL frontend)
- name: Configure Nginx for Prometheus
become: true
hosts: prometheus
vars_files:
- vault.yml
tasks:
- name: Set SELinux booleans for nginx
tags:
- monitoring
- nginx
seboolean:
state: true
name: httpd_can_network_connect
persistent: yes
when: ansible_distribution_file_variety == 'RedHat'
- import_role:
name: ansible-role-nginx
tags:
- monitoring
- nginx
vars:
nginx_yum_repo_enabled: false
nginx_vhosts:
- listen: "443 ssl http2"
server_name: "{{ ansible_fqdn }}"
extra_parameters: |
location / {
proxy_pass http://localhost:9090/;
}
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 1h;
ssl_session_tickets on;
ssl_certificate "{{ ssl_dir }}/certs/{{ ansible_fqdn }}.pem";
ssl_certificate_key "{{ ssl_dir }}/private/{{ ansible_fqdn }}.key";
ssl_protocols TLSv1.2;
ssl_ciphers EECDH+AESGCM:EDH+AESGCM:!ADH:!AECDH:!MD5;
ssl_prefer_server_ciphers on;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
#########################################################################################
# Prometheus
- name: Configure Prometheus
become: true
hosts: prometheus
vars_files:
- vault.yml
tasks:
- import_role:
name: ansible-prometheus
tags:
- monitoring
- prometheus
- import_role:
name: ansible-alertmanager
tags:
- monitoring
- prometheus
- import_role:
name: ansible-pushgateway
tags:
- monitoring
- prometheus
- import_role:
name: ansible-collectd-exporter
tags:
- monitoring
- prometheus
- import_role:
name: ansible-statsd-exporter
tags:
- monitoring
- prometheus
- import_role:
name: ansible-snmp-exporter
tags:
- monitoring
- prometheus
- import_role:
name: ansible-blackbox-exporter
tags:
- monitoring
- prometheus
vars:
blackbox_exporter_configuration_modules:
http_2xx:
prober: http
timeout: 5s
http:
preferred_ip_protocol: ip4
method: GET
valid_status_codes: []
tcp_connect:
prober: tcp
timeout: 5s
ssh_banner:
prober: tcp
timeout: 5s
tcp:
query_response:
- expect: "^SSH-2.0-"
icmp_test:
prober: icmp
timeout: 5s
icmp:
preferred_ip_protocol: ip4
dns_a:
prober: dns
timeout: 5s
dns:
preferred_ip_protocol: ip4
query_name: "google.com"
query_type: "A"
validate_answer_rrs:
fail_if_matches_regexp:
- test
dns_mx:
prober: dns
timeout: 5s
dns:
preferred_ip_protocol: ip4
query_name: "google.com"
query_type: "MX"
validate_answer_rrs:
fail_if_not_matches_regexp:
- "google.com.\t.*\tIN\tMX\t.*google.*"
- import_role:
name: ansible-ovirt-exporter
tags:
- monitoring
- prometheus
when: ovirt_exporter is defined and ovirt_exporter
- import_role:
name: ansible-ipmi-exporter
tags:
- monitoring
- prometheus
when: ipmi_exporter is defined and ipmi_exporter
vars:
ipmi_exporter_configuration_modules:
default:
collectors: []
user: default_user
pass: example_pw
privilege: user
driver: LAN_2_0
timeout: 10000
exclude_sensor_ids: []
ipmi_lan2:
collectors:
- bmc
- ipmi
- chassis
- sel
- dcmi
user: prometheus
pass: "{{ vault_ipmi_pass }}"
privilege: user
driver: LAN_2_0
timeout: 10000
exclude_sensor_ids: []
ipmi_lan:
collectors:
- bmc
- ipmi
- chassis
- sel
- dcmi
user: prometheus
pass: "{{ vault_ipmi_pass }}"
privilege: user
driver: LAN
timeout: 10000
exclude_sensor_ids: []
- name: Create target directories
tags:
- monitoring
- prometheus
- prometheus_targets
file:
path: "/etc/prometheus/{{ item }}"
state: directory
owner: prometheus
group: prometheus
mode: '0755'
with_items:
- nodeexporter
- snmpexporter
- blackboxexporter
- exporters
- name: Deploy local node_exporter configuration
tags:
- monitoring
- prometheus
- prometheus_targets
template:
src: "prometheus/local_exporter.yml.j2"
dest: /etc/prometheus/nodeexporter/local_http_targets.yml
owner: prometheus
group: prometheus
mode: '0644'
- name: Deploy node_exporter target configurations
tags:
- monitoring
- prometheus
- prometheus_targets
template:
src: "prometheus/exporter_targets.yml.j2"
dest: "/etc/prometheus/nodeexporter/{{ item.project }}_http_targets.yml"
owner: prometheus
group: prometheus
mode: '0644'
with_items: "{{ prometheus_node_exporter_targets }}"
when: prometheus_node_exporter_targets is defined and prometheus_node_exporter_targets|length > 0
- name: Deploy tls_node_exporter target configurations
tags:
- monitoring
- prometheus
- prometheus_targets
template:
src: "prometheus/exporter_targets.yml.j2"
dest: "/etc/prometheus/nodeexporter/{{ item.project }}_tls_targets.yml"
owner: prometheus
group: prometheus
mode: '0644'
with_items: "{{ prometheus_tls_node_exporter_targets }}"
when: prometheus_tls_node_exporter_targets is defined and prometheus_tls_node_exporter_targets|length > 0
- name: Deploy wmi_exporter target configurations
tags:
- monitoring
- prometheus
- prometheus_targets
template:
src: "prometheus/exporter_targets.yml.j2"
dest: "/etc/prometheus/exporters/{{ item.project }}_wmi_targets.yml"
owner: prometheus
group: prometheus
mode: '0644'
with_items: "{{ prometheus_wmi_exporter_targets }}"
when: prometheus_wmi_exporter_targets is defined and prometheus_wmi_exporter_targets|length > 0
- name: Deploy grafana exporter configuration
tags:
- monitoring
- prometheus
- prometheus_targets
template:
src: "prometheus/exporter_targets.yml.j2"
dest: /etc/prometheus/exporters/grafana_targets.yml
owner: prometheus
group: prometheus
mode: '0644'
with_items: "{{ prometheus_grafana_exporter_targets }}"
when: prometheus_grafana_exporter_targets is defined and prometheus_grafana_exporter_targets|length > 0
- name: Deploy snmp_exporter target configurations
tags:
- monitoring
- prometheus
- prometheus_targets
template:
src: "prometheus/exporter_targets.yml.j2"
dest: "/etc/prometheus/snmpexporter/{{ item[0].project }}_targets.yml"
owner: prometheus
group: prometheus
mode: '0644'
with_subelements:
- "{{ prometheus_snmp_exporter_targets }}"
- targets
when: prometheus_snmp_exporter_targets is defined and prometheus_snmp_exporter_targets|length > 0
- name: Deploy blackbox_exporter HTTP target configurations
tags:
- monitoring
- prometheus
- prometheus_targets
template:
src: "prometheus/exporter_targets.yml.j2"
dest: "/etc/prometheus/blackboxexporter/{{ item.project }}_http_targets.yml"
owner: prometheus
group: prometheus
mode: '0644'
with_items: "{{ prometheus_blackbox_exporter_http_targets }}"
when: prometheus_blackbox_exporter_http_targets is defined and prometheus_blackbox_exporter_http_targets|length > 0
- name: Deploy blackbox_exporter DNS target configurations
tags:
- monitoring
- prometheus
- prometheus_targets
template:
src: "prometheus/exporter_targets.yml.j2"
dest: "/etc/prometheus/blackboxexporter/{{ item.project }}_dns_targets.yml"
owner: prometheus
group: prometheus
mode: '0644'
with_items: "{{ prometheus_blackbox_exporter_dns_targets }}"
when: prometheus_blackbox_exporter_dns_targets is defined and prometheus_blackbox_exporter_dns_targets|length > 0
- name: Deploy blackbox_exporter ICMP target configurations
tags:
- monitoring
- prometheus
- prometheus_targets
template:
src: "prometheus/exporter_targets.yml.j2"
dest: "/etc/prometheus/blackboxexporter/{{ item.project }}_icmp_targets.yml"
owner: prometheus
group: prometheus
mode: '0644'
with_items: "{{ prometheus_blackbox_exporter_icmp_targets }}"
when: prometheus_blackbox_exporter_icmp_targets is defined and prometheus_blackbox_exporter_icmp_targets|length > 0
- name: Deploy ipa_exporter target configurations
tags:
- monitoring
- prometheus
- prometheus_targets
template:
src: "prometheus/exporter_targets.yml.j2"
dest: "/etc/prometheus/exporters/{{ item.project }}_ipa_targets.yml"
owner: prometheus
group: prometheus
mode: '0644'
with_items: "{{ prometheus_ipa_exporter_targets }}"
when: prometheus_ipa_exporter_targets is defined and prometheus_ipa_exporter_targets|length > 0
- name: Deploy vdsm_exporter target configurations
tags:
- monitoring
- prometheus
- prometheus_targets
template:
src: "prometheus/exporter_targets.yml.j2"
dest: "/etc/prometheus/exporters/{{ item.project }}_vdsm_targets.yml"
owner: prometheus
group: prometheus
mode: '0644'
with_items: "{{ prometheus_vdsm_exporter_targets }}"
when: prometheus_vdsm_exporter_targets is defined and prometheus_vdsm_exporter_targets|length > 0
- name: Deploy NiFi exporter configuration
tags:
- monitoring
- prometheus
- prometheus_targets
template:
src: "prometheus/exporter_targets.yml.j2"
dest: /etc/prometheus/exporters/{{ item.project }}_nifi_targets.yml
owner: prometheus
group: prometheus
mode: '0644'
with_items: "{{ prometheus_nifi_exporter_targets }}"
when: prometheus_nifi_exporter_targets is defined and prometheus_nifi_exporter_targets|length > 0
- name: Deploy Artifactory exporter configuration
tags:
- monitoring
- prometheus
- prometheus_targets
template:
src: "prometheus/exporter_targets.yml.j2"
dest: /etc/prometheus/exporters/{{ item.project }}_artifactory_targets.yml
owner: prometheus
group: prometheus
mode: '0644'
with_items: "{{ prometheus_artifactory_exporter_targets }}"
when: prometheus_artifactory_exporter_targets is defined and prometheus_artifactory_exporter_targets|length > 0
- name: Deploy IPMI exporter configuration
tags:
- monitoring
- prometheus
- prometheus_targets
template:
src: "prometheus/exporter_targets.yml.j2"
dest: /etc/prometheus/exporters/{{ item.project }}_ipmi_targets.yml
owner: prometheus
group: prometheus
mode: '0644'
with_items: "{{ prometheus_ipmi_exporter_targets }}"
when: prometheus_ipmi_exporter_targets is defined and prometheus_ipmi_exporter_targets|length > 0
# Not done inside role (Only needed if we are federating Prometheus)
- name: Open Prometheus firewall ports to receive push events
tags:
- monitoring
- prometheus
firewalld:
port: "{{ item }}"
immediate: yes
permanent: yes
state: enabled
with_items:
- 9091/tcp # pushgateway
- 9093/tcp # alertmanager
- 8125/tcp # statsd
- 8125/udp # statsd
- 25826/udp # collectd
- name: Open Prometheus firewall port
tags:
- monitoring
- prometheus
firewalld:
service: 'https'
immediate: yes
permanent: yes
state: enabled