taler-docs

Documentation for GNU Taler components, APIs and protocols
Log | Files | Refs | README | LICENSE

commit c2428d6d8f13b77e1423b73622346c28254ce262
parent 99be1a35a05dbe0995610551b3ccb9918fff9d51
Author: Javier Sepulveda <javier.sepulveda@uv.es>
Date:   Fri,  5 Jul 2024 10:45:31 +0200

Nginx prometheus exporter tutorial

Diffstat:
Msystem-administration/index.rst | 2+-
Asystem-administration/nginx-prometheus-exporter.rst | 150+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 151 insertions(+), 1 deletion(-)

diff --git a/system-administration/index.rst b/system-administration/index.rst @@ -25,5 +25,5 @@ System Administration tutorials lego-certificates taler-monitoring-infrastructure borgbackup-tutorial - writing-documentation-setup prometheus + nginx-prometheus-exporter diff --git a/system-administration/nginx-prometheus-exporter.rst b/system-administration/nginx-prometheus-exporter.rst @@ -0,0 +1,150 @@ +.. + This file is part of GNU TALER. + Copyright (C) 2014-2023 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free Software + Foundation; either version 2.1, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + + @author Javier Sepulveda + + +Nginx Prometheus Exporter +######################### + +.. contents:: Table of Contents + :depth: 1 + :local: + +Download nginx-prometheus-exporter +================================== + +* Download +* Extract +* Copy to /usr/local/bin +* Set ownership and permissions + +.. code-block:: console + + # mkdir -p /tmp/nginx_exporter_tmp && cd /tmp/nginx_exporter_tmp + # wget https://github.com/nginxinc/nginx-prometheus-exporter/releases/download/v1.2.0/nginx-prometheus-exporter_1.2.0_linux_amd64.tar.gz + # tar axf nginx-prometheus-exporter_1.2.0_linux_amd64.tar.gz + # cd nginx-prometheus-exporter + # cp nginx-prometheus-exporter /usr/local/bin + + +Create a system user +==================== + +.. code-block:: console + + # useradd --system --no-create-home --shell /bin/false nginx-exporter + + +Systemd configuration +===================== + +Nginx-prometheus-exporter systemd service file +---------------------------------------------- + +.. code-block:: systemd + + # Path:/etc/systemd/system/nginx-exporter.service + + [Unit] + Description=NGINX Prometheus Exporter + Requires=nginx-exporter.socket + + [Service] + User=nginx-exporter + ExecStart=/usr/local/bin/nginx-prometheus-exporter --nginx.scrape-uri="http://127.0.0.1/metrics" --web.systemd-socket + + [Install] + WantedBy=multi-user.target + + +Nginx-prometheus-exporter systemd socket file +--------------------------------------------- + +.. code-block:: systemd + + # Path: /etc/systemd/system/nginx-exporter.socket + + [Unit] + Description=NGINX Prometheus Exporter + + [Socket] + ListenStream=9113 + + [Install] + WantedBy=sockets.target + +Modify the Prometheus configuration file +======================================== + +.. code-block:: yaml + + # Path: /etc/prometheus/prometheus.yml + + # Job, for nginx_exporter + - job_name: 'nginx_exporter' + static_configs: + - targets: ['localhost:9113'] # choose port number + + +Nginx configuration +=================== + +.. code-block:: nginx + + server { + listen localhost; + root /var/www/html; + index index.html; + server_name _; + + location /metrics { + stub_status on; + access_log off; + allow 127.0.0.1; + deny all; + } + + } + + +.. code-block:: console + + ## Create the Nginx symbolic link to enable the virtualhost file + # ln -s /etc/nginx/sites-available/nginx-exporter.conf /etc/nginx/sites-enabled/nginx-exporter.conf + # nginx -t + # systemctl reload nginx + ## Check with curl + # curl http://localhost/metrics + +Restart everything +================== + +.. code-block:: console + + # systemctl daemon-reload # Only necessary if modified + # systemctl enable --now node-exporter.service + # systemctl status node-exporter.service + # systemctl restart prometheus.service + + +Create a new dashboard in Grafana +================================= + +You can now go to our `grafana.taler.net dasboards <a href="https://grafana.taler.net/dashboards">`_ and easily +add the new dashboard for the Nginx Exporter program. Please make sure you choose the right Prometheus data source. + +* Dashboard Id: 11199 +* Dashboard URL: https://grafana.com/grafana/dashboards/11199-nginx/