From fb191f27d6f5f9ec22e5c0be06fd2b07d651dfa7 Mon Sep 17 00:00:00 2001 From: Ludovic Cartier Date: Fri, 21 Apr 2023 15:16:01 +0200 Subject: [PATCH] add nginx exporter --- defaults/main.yml | 3 +++ tasks/exporter/nginx.yml | 3 +++ tasks/main.yml | 1 + .../systemd/prometheus-nginx-exporter.service.j2 | 12 ++++++++++++ 4 files changed, 19 insertions(+) create mode 100644 tasks/exporter/nginx.yml create mode 100644 templates/systemd/prometheus-nginx-exporter.service.j2 diff --git a/defaults/main.yml b/defaults/main.yml index a1b2542..ef173c3 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -17,6 +17,7 @@ prometheus_repo_blackbox: prometheus prometheus_repo_memcached: prometheus prometheus_repo_mongodb: percona prometheus_repo_mysqld: prometheus +prometheus_repo_nginx: tchivert prometheus_repo_node: prometheus prometheus_repo_opcache: tchivert prometheus_repo_phpfpm: Lusitaniae @@ -49,6 +50,8 @@ prometheus_mongodb_exporter_database: "admin" prometheus_mongodb_exporter_host: "localhost" prometheus_mongodb_exporter_port: 27017 +prometheus_nginx_scrape_uri: "http://localhost/stub_status" + prometheus_opcache_exporter_fcgi_uri: "unix:///var/run/www.sock" prometheus_phpfpm_sockets_directory: "/run/php/" diff --git a/tasks/exporter/nginx.yml b/tasks/exporter/nginx.yml new file mode 100644 index 0000000..5789c1b --- /dev/null +++ b/tasks/exporter/nginx.yml @@ -0,0 +1,3 @@ +--- +- include_tasks: _common.yml + tags: ['prometheus_nginx_exporter'] diff --git a/tasks/main.yml b/tasks/main.yml index 6432510..88fefcd 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -39,5 +39,6 @@ - prometheus_opcache_exporter - prometheus_blackbox_exporter - prometheus_kong_exporter + - prometheus_nginx_exporter with_items: - "{{ prometheus_exporter_packages }}" diff --git a/templates/systemd/prometheus-nginx-exporter.service.j2 b/templates/systemd/prometheus-nginx-exporter.service.j2 new file mode 100644 index 0000000..afbfc44 --- /dev/null +++ b/templates/systemd/prometheus-nginx-exporter.service.j2 @@ -0,0 +1,12 @@ +[Unit] +Description=Prometheus Nginx Exporter +After=network.target + +[Service] +Type=simple +ExecStart=/usr/local/bin/prometheus-nginx-exporter \ +-nginx.scrape-uri {{ prometheus_nginx_scrape_uri }} \ +-web.listen-address=0.0.0.0:9113 + +[Install] +WantedBy=multi-user.target