[prometheus] Replace targets deployment by a service

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
ntpsec
Yohann D'ANELLO 2022-08-04 11:30:32 +02:00
parent 9e4d157743
commit e21dbc7781
Signed by: _ynerant
GPG Key ID: 3A75C55819C8CF85
4 changed files with 23 additions and 24 deletions

View File

@ -1,6 +1,20 @@
---
glob_prometheus: {}
glob_service_prometheus_target:
git:
remote: https://gitlab.adm.crans.org/nounous/prometheus-target.git
version: main
name: prometheus-target
install_dir: /var/local/services/prometheus-target
generated: false
cron:
frequency: "*/10 * * * *"
options: ""
config:
ldap:
server: "ldaps://{{ query('ldap', 'ip', 'tealc', 'adm') | ansible.utils.ipv4 | first }}"
glob_ninjabot:
config:
nick: fyre

View File

@ -5,8 +5,6 @@ interfaces:
loc_prometheus:
node:
file: targets_node.json
targets: "{{ groups['server'] | select('match', '^.*\\.adm\\.crans\\.org$') | list | sort }}"
config:
- job_name: servers
file_sd_configs:
@ -22,8 +20,6 @@ loc_prometheus:
replacement: '$1:9100'
nginx:
file: targets_nginx.json
targets: "{{ groups['nginx'] | select('match', '^.*\\.adm\\.crans\\.org$') | list | sort }}"
config:
- job_name: nginx
file_sd_configs:
@ -77,11 +73,6 @@ loc_prometheus:
replacement: 127.0.0.1:9115
blackbox_icmp:
file: targets_icmp.json
targets:
- karst.adm.crans.org
- horst.adm.crans.org
- rodney.adm.crans.org
config:
- job_name: blackbox_icmp
file_sd_configs:
@ -99,8 +90,6 @@ loc_prometheus:
replacement: 127.0.0.1:9115
bird:
file: targets_bird.json
targets: "{{ groups['bird'] | select('match', '^.*\\.adm\\.crans\\.org$') | list | sort }}"
config:
- job_name: bird
file_sd_configs:
@ -116,23 +105,21 @@ loc_prometheus:
replacement: '$1:9324'
mtail:
file: targets_mtail.json
targets:
- tealc.adm.crans.org
config:
- job_name: mtail
static_configs:
- targets: ["tealc.adm.crans.org"]
file_sd_configs:
- files:
- '/etc/prometheus/targets_mtail.json'
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- source_labels: [instance]
- source_labels: [__param_target]
target_label: __address__
replacement: '$1:3903'
ilo_snmp:
file: targets_ilo_snmp.json
targets: "{{ groups['ilo_snmp'] | select('match', '^.*\\.adm\\.crans\\.org$') | list | sort }}"
config:
- job_name: ilo_snmp
file_sd_configs:
@ -151,9 +138,6 @@ loc_prometheus:
target_label: __address__
ups_snmp:
file: targets_ups_snmp.json
targets:
- excalibur.adm.crans.org
config:
- job_name: ups_snmp
file_sd_configs:
@ -174,8 +158,6 @@ loc_prometheus:
target_label: __address__
printer_snmp:
file: targets_printer.json
targets: ["printer.lp.crans.org"]
config:
- job_name: printer_snmp
static_configs:

View File

@ -4,8 +4,10 @@
- hosts: prometheus
vars:
prometheus: "{{ glob_prometheus | default({}) | combine(loc_prometheus | default({})) }}"
service: "{{ glob_service_prometheus_target | default({}) | combine(loc_service_prometheus_target | default({})) }}"
roles:
- prometheus
- service
- hosts: prometheus_alertmanager
vars:

View File

@ -28,6 +28,7 @@
dest: /etc/prometheus/{{ item.value.file }}
mode: 0644
loop: "{{ prometheus | dict2items }}"
when: "item.value.file is defined"
- name: Activate prometheus service
systemd: