From e01e57190687dd20aab722cad6c827f4ca47049d Mon Sep 17 00:00:00 2001 From: Camille Prugnard Date: Fri, 8 Oct 2021 14:40:13 +0200 Subject: [PATCH] add haproxy scraping for use with builtin haproxy exporter --- README.md | 44 ++++++++++++++++---------------- templates/conf/prometheus.yml.j2 | 11 ++++++++ 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 40c5838..118bd58 100644 --- a/README.md +++ b/README.md @@ -12,28 +12,28 @@ It has been tested on : Role variables -------------- -| Variable | Type | Choices | Default | Comment | -|----------------------------------------------|---------|--------------------------------------------------------|-------------|-----------------| -| prometheus_server_enable | string | true / false | | | -| prometheus_server_version | string | | latest | | -| prometheus_server_monitor | string | | | | -| prometheus_server_global_scrape_interval | string | | 15 | | -| prometheus_server_global_evaluation_interval | string | | 15 | | -| prometheus_server_job_name | string | | prometheus | | -| prometheus_server_scrape_interval | string | | 5 | | -| prometheus_server_scrape_timeout | string | | 5 | | -| prometheus_exporter_packages | list | node / mysqld / postgresql / mongodb / phpfpm / apache | | | -| prometheus_node_exporter_targets | list | | | | -| prometheus_mysqld_exporter_targets | list | | | | -| prometheus_mongodb_exporter_targets | list | | | | -| prometheus_postgres_exporter_targets | list | | | | -| prometheus_mysqld_exporter_user | string | | | | -| prometheus_mysqld_exporter_password | string | | | | -| prometheus_mongodb_exporter_host | string | | localhost | | -| prometheus_mongodb_exporter_port | string | | 27017 | | -| prometheus_mongodb_exporter_user | string | | | | -| prometheus_mongodb_exporter_pass | string | | | | -| prometheus_server_version | string | | latest | | +| Variable | Type | Choices | Default | Comment | +|----------------------------------------------|---------|------------------------------------------------------------------|-------------|-----------------| +| prometheus_server_enable | string | true / false | | | +| prometheus_server_version | string | | latest | | +| prometheus_server_monitor | string | | | | +| prometheus_server_global_scrape_interval | string | | 15 | | +| prometheus_server_global_evaluation_interval | string | | 15 | | +| prometheus_server_job_name | string | | prometheus | | +| prometheus_server_scrape_interval | string | | 5 | | +| prometheus_server_scrape_timeout | string | | 5 | | +| prometheus_exporter_packages | list | node / mysqld / postgresql / mongodb / phpfpm / apache / haproxy | | | +| prometheus_node_exporter_targets | list | | | | +| prometheus_mysqld_exporter_targets | list | | | | +| prometheus_mongodb_exporter_targets | list | | | | +| prometheus_postgres_exporter_targets | list | | | | +| prometheus_mysqld_exporter_user | string | | | | +| prometheus_mysqld_exporter_password | string | | | | +| prometheus_mongodb_exporter_host | string | | localhost | | +| prometheus_mongodb_exporter_port | string | | 27017 | | +| prometheus_mongodb_exporter_user | string | | | | +| prometheus_mongodb_exporter_pass | string | | | | +| prometheus_server_version | string | | latest | | Dependencies ------------ diff --git a/templates/conf/prometheus.yml.j2 b/templates/conf/prometheus.yml.j2 index a051d9b..dd20d51 100644 --- a/templates/conf/prometheus.yml.j2 +++ b/templates/conf/prometheus.yml.j2 @@ -96,3 +96,14 @@ scrape_configs: - {{ target }}:9117 {% endfor %} {% endif %} + +{% if prometheus_haproxy_exporter_targets is defined %} + - job_name: haproxy + scrape_interval: 30s + scrape_timeout: 10s + static_configs: + - targets: +{% for target in prometheus_haproxy_exporter_targets %} + - {{ target }}:8404 +{% endfor %} +{% endif %}