1
0
Fork
You've already forked nginxlogs
0
Monitorize Mastodon server's nginx logs from Grafana dashboard. Total requests, successfull requests, server errors, client errors and so on.
  • Python 100%
2025年09月11日 23:01:38 +02:00
app/libraries Increased method columns to varchar(20) 2025年09月11日 23:01:38 +02:00
conf Added 2025年08月14日 16:55:49 +02:00
dashboard Updated README.md. Added links to Grafana dashboard and example image. 2025年08月18日 20:51:34 +02:00
images Updated README.md. Added links to Grafana dashboard and example image. 2025年08月18日 20:51:34 +02:00
backlog.py Refactor. Added backlog.py 2025年08月17日 13:44:28 +02:00
fetchlogs.py Refactor. Added backlog.py 2025年08月17日 13:44:28 +02:00
hourly.py Refactor. Added backlog.py 2025年08月17日 13:44:28 +02:00
LICENSE Added 2025年08月14日 16:55:08 +02:00
README.md Updated README.md. Added links to Grafana dashboard and example image. 2025年08月18日 20:51:34 +02:00
requirements.txt Fixed Database class errors. Added fetchlogs.py. Updated README.md. 2025年08月14日 20:52:55 +02:00

nginxlogs

Monitorize Mastodon server's nginx logs from Grafana dashboard. Total requests, successfull requests, server errors, client errors and so on.

Dependencies

  • Python 3
  • Postgresql server
  • Grafana server
  • Mastodon server (owner)
  • system user added to adm group

Usage:

  1. As your chosen system user, git clone this repository git clone https://codeberg.org/spla/nginxlogs.git

  2. cp conf/custom_json.conf /etc/nginx/conf.d/ to map nginx's vars to json format.

  3. As root, add access_log /var/log/nginx/<your_mastodon_domain>_json.access.log json_analytics; to your Mastodon server's nginx conf into server block.

  4. Still as root, run nginx -t to make sure nginx likes new config, then reload it systemctl reload nginx.

  5. Back to your system user, cd nginxlogs, python3.x -m venv ., source bin/activate and pip install -r requirements.txt to install needed Python libraries.

  6. Run python fetchlogs.py to configure everything, create database and fetch last 14 days nginx logs of your Mastodon server.

  7. Now run python backlog.py to calc and save stats from above fetched nginx logs.

  8. Then run python hourly.py to start collecting and saving real time json formatted nginx log data to nginx_stats table of the new Postgresql database created at step 6. This nginx_stats table will be the Grafana's datasource.

  9. Use your favourite method to keep python hourly.py running to generate stats every minute.

Grafana:

  1. Add a new Postgresql datasource from Postgresql database's table nginx_stats.

  2. Import this Grafana dashboard and enjoy.

Grafana Dashboard