handle postgresql

This commit is contained in:
Ludovic Cartier 2021-10-29 18:16:32 +02:00
parent 97a4f54b40
commit 0332bad2bd
3 changed files with 18 additions and 0 deletions

View File

@ -17,6 +17,9 @@ prometheus_phpfpm_sockets_directory: "/run/php/"
prometheus_postgres_exporter_host: "/var/run/postgresql/" prometheus_postgres_exporter_host: "/var/run/postgresql/"
prometheus_postgres_exporter_sslmode: "disable" prometheus_postgres_exporter_sslmode: "disable"
prometheus_postgres_exporter_user: "postgres" prometheus_postgres_exporter_user: "postgres"
prometheus_postgres_exporter_password: "changeme_"
prometheus_postgres_exporter_port: 5432
prometheus_retention_time: "15d" prometheus_retention_time: "15d"

View File

@ -1,2 +1,6 @@
# {{ ansible_managed }} # {{ ansible_managed }}
{% if (prometheus_postgres_exporter_user is defined) and (prometheus_postgres_exporter_password is defined) %}
DATA_SOURCE_NAME=postgresql://{{ prometheus_postgres_exporter_user }}:{{ prometheus_postgres_exporter_password }}@{{ prometheus_postgres_exporter_host }}:{{ prometheus_postgres_exporter_port }}/postgres?sslmode=prometheus_postgres_exporter_sslmode
{% else %}
DATA_SOURCE_NAME="user={{ prometheus_postgres_exporter_user }} host={{ prometheus_postgres_exporter_host }} sslmode={{ prometheus_postgres_exporter_sslmode }}" DATA_SOURCE_NAME="user={{ prometheus_postgres_exporter_user }} host={{ prometheus_postgres_exporter_host }} sslmode={{ prometheus_postgres_exporter_sslmode }}"
{% endif %}

View File

@ -91,11 +91,22 @@ scrape_configs:
scrape_interval: 30s scrape_interval: 30s
scrape_timeout: 10s scrape_timeout: 10s
static_configs: static_configs:
{% if prometheus_postgres_exporter_custom is defined %}
{% for target in prometheus_postgres_exporter_custom.values() %}
- targets: ['{{ target.node_name }}:9187']
labels:
environment: '{{ target.environment }}'
node_name: '{{ target.node_name }}'
service_name: '{{ target.service_name }}'
cluster: '{{ target.cluster }}'
{% endfor %}
{% else %}
- targets: - targets:
{% for target in prometheus_postgres_exporter_targets %} {% for target in prometheus_postgres_exporter_targets %}
- {{ target }}:9187 - {{ target }}:9187
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% endif %}
{% if prometheus_phpfpm_exporter_targets is defined %} {% if prometheus_phpfpm_exporter_targets is defined %}
- job_name: phpfpm - job_name: phpfpm