Install postgres exporter
This commit is contained in:
parent
3d1d787063
commit
45041be2ab
3 changed files with 51 additions and 0 deletions
|
@ -151,6 +151,11 @@
|
||||||
roles:
|
roles:
|
||||||
- prometheus_federate
|
- prometheus_federate
|
||||||
|
|
||||||
|
#Postgres Exporters
|
||||||
|
- hosts: bdd.adm.auro.re,bdd-ovh.adm.auro.re
|
||||||
|
roles:
|
||||||
|
- prometheus_postgres
|
||||||
|
|
||||||
|
|
||||||
# Monitor all hosts
|
# Monitor all hosts
|
||||||
- hosts: all,!edc_unifi,!fleming_unifi,!pacaterie_unifi,!gs_unifi,!rives_unifi,!aurore_testing_vm,!ovh_container
|
- hosts: all,!edc_unifi,!fleming_unifi,!pacaterie_unifi,!gs_unifi,!rives_unifi,!aurore_testing_vm,!ovh_container
|
||||||
|
|
5
roles/prometheus_postgres/handlers/main.yml
Normal file
5
roles/prometheus_postgres/handlers/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
- name: Restart prometheus-postgres-exporter
|
||||||
|
service:
|
||||||
|
name: prometheus-postgres-exporter
|
||||||
|
state: restarted
|
41
roles/prometheus_postgres/tasks/main.yml
Normal file
41
roles/prometheus_postgres/tasks/main.yml
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
---
|
||||||
|
- name: Install Prometheus postgres-exporter
|
||||||
|
apt:
|
||||||
|
update_cache: true
|
||||||
|
name: prometheus-postgres-exporter
|
||||||
|
register: apt_result
|
||||||
|
retries: 3
|
||||||
|
until: apt_result is succeeded
|
||||||
|
when:
|
||||||
|
- ansible_lsb.codename == 'bullseye'
|
||||||
|
|
||||||
|
- name: Make Prometheus postgres-exporter connect to databases using peercred
|
||||||
|
lineinfile:
|
||||||
|
path: /etc/default/prometheus-postgres-exporter
|
||||||
|
regexp: '^DATA_SOURCE_NAME='
|
||||||
|
line: |
|
||||||
|
DATA_SOURCE_NAME="user=postgres host=/var/run/postgresql/ sslmode=disable"
|
||||||
|
notify: Restart prometheus-postgres-exporter
|
||||||
|
|
||||||
|
- name: Make Prometheus postgres-exporter launched by postgres user
|
||||||
|
lineinfile:
|
||||||
|
path: /lib/systemd/system/prometheus-postgres-exporter.service
|
||||||
|
regexp: '^User='
|
||||||
|
line: |
|
||||||
|
User=postgres
|
||||||
|
notify: Restart prometheus-postgres-exporter
|
||||||
|
|
||||||
|
- name: Make Prometheus postgres-exporter listen on adm only
|
||||||
|
lineinfile:
|
||||||
|
path: /etc/default/prometheus-postgres-exporter
|
||||||
|
regexp: '^ARGS='
|
||||||
|
line: |
|
||||||
|
ARGS="--web.listen-address={{ ansible_hostname }}.adm.auro.re:9187"
|
||||||
|
notify: Restart prometheus-postgres-exporter
|
||||||
|
|
||||||
|
- name: Activate prometheus-postgres-exporter service
|
||||||
|
systemd:
|
||||||
|
name: prometheus-postgres-exporter
|
||||||
|
enabled: true
|
||||||
|
daemon_reload: yes
|
||||||
|
state: started
|
Loading…
Reference in a new issue