Configuration of Prometheus uWSGI Expoter

Configuration of Prometheus uWSGI Expoter

Introduction

uWSGI_expoter is a Prometheus exporter. I made for work with uWSGI in eperor mode, than a server with multiples application, Django or Wordpress. It can also monitor a single web application.

Prerequisites:

  • Prometheus suite working: Prometheus, AlarmManger, Tutorial
  • uWsgi istance, with monitoring socket enabled, Tutorial

Installation

User for exporter

Create a new user for exporter, i call prometheus.

sudo adduser prometheus --system \
                   --no-create-home \
                   --shell /sbin/nologin

Dowload and install binary

Dowload last binary version from:https://github.com/AndreaGreco/prometeus_uwsgi_exporter/releases, and unzip it. This guide is made for version 1.0

wget https://github.com/AndreaGreco/prometeus_uwsgi_exporter/releases/download/v1.0/uWSGI_Exporter.tar.xz
tar -xf uWSGI_Exporter.tar.xz
mv -v uWSGI_Exporter /opt/

Install service with Systemd

Install Systemd unit:

# pwd: /opt/uWSGI_Exporter

mv -v uwsgi_expoter.service /etc/systemd/system/
systemctl daemon-reload

Configuration

port: 9238
socket_dir: "/run/uwsgi/stats/"
pidfile: "/run/uwsgi_expoter.pid"
stats_sockets:

- domain: your.domain.com
  socket: your_socket_name.sock

- domain: other-domain.com
  socket: other_socket_domain.sock

Socket_dir: Folder where search uwsgi statistcs soket socket

pidfile: PID of service

stats_sockets: List for socket and related domain

  • domain: String of monitored, domain; This is a simple string is not necessary real domain of service.
  • socket: Path of related socket.

Start service with:

systemctl start uwsgi_expoter

If there a firewall on your server remeber open associated port.

Then configure Prometheus by adding exporter.

If you use Grafana for make graph, there a premade bashboard, dowload it from: https://grafana.com/dashboards/3435