- Python 100%
| app/libraries | Increased method columns to varchar(20) | |
| conf | Added | |
| dashboard | Updated README.md. Added links to Grafana dashboard and example image. | |
| images | Updated README.md. Added links to Grafana dashboard and example image. | |
| backlog.py | Refactor. Added backlog.py | |
| fetchlogs.py | Refactor. Added backlog.py | |
| hourly.py | Refactor. Added backlog.py | |
| LICENSE | Added | |
| README.md | Updated README.md. Added links to Grafana dashboard and example image. | |
| requirements.txt | Fixed Database class errors. Added fetchlogs.py. Updated README.md. | |
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:
-
As your chosen system user, git clone this repository
git clone https://codeberg.org/spla/nginxlogs.git -
cp conf/custom_json.conf /etc/nginx/conf.d/to map nginx's vars to json format. -
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. -
Still as root, run
nginx -tto make sure nginx likes new config, then reload itsystemctl reload nginx. -
Back to your system user,
cd nginxlogs,python3.x -m venv .,source bin/activateandpip install -r requirements.txtto install needed Python libraries. -
Run
python fetchlogs.pyto configure everything, create database and fetch last 14 days nginx logs of your Mastodon server. -
Now run
python backlog.pyto calc and save stats from above fetched nginx logs. -
Then run
python hourly.pyto 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. -
Use your favourite method to keep
python hourly.pyrunning to generate stats every minute.
Grafana:
-
Add a new Postgresql datasource from Postgresql database's table nginx_stats.
-
Import this Grafana dashboard and enjoy.