Collects and tracks various stats of your Nexus Mods mods.
git clone
this repository to your server.- Install dependencies:
pip install toml
. Consider using a virtual environment.- for Prometheus:
pip install prometheus_client
- for TimescaleDB: install the PostgreSQL development package (e.g.
libpq-dev
on Debian/Ubuntu,libpqxx-devel
on Fedora) andpip install psycopg2
- for Prometheus:
- Copy
documentation/config.toml.example
toconfig.toml
. Modify it to your needs and list the games and mods you want to track. Read the comments for more information on how to format your settings. - Get an API key from https://www.nexusmods.com/users/myaccount?tab=api and save it to your
config.toml
. Take care that nobody but you can access your API key!
The recommended setup is to set up timescaledb_exporter.py
for use with timescaleDB and Grafana.
To print stats to stdout once (e.g. testing your setup), run ./crawler.py
, or pipe to file: ./crawler.py > crawler.out
.
To export metrics to Prometheus:
- Install Prometheus
- Run
./prometheus_exporter.py
as a daemon. - Set Prometheus to scrape from the running script (default
localhost:8000
) with scrape interval matching the script's"min update interval"
.
To export metrics to TimescaleDB:
- Install PostgreSQL + TimescaleDB
- Depending on your setup, enable network-based access:
listen_addresses
inpostgresql.conf
, authentication inpg_hba.conf
. - Set up a user, password, and database (instructions). Add this configuration to your
config.toml
. - Run
./timescale_exporter.py
as a daemon.
To display metrics with Grafana:
- Set up your Grafana dashboards using the provided Prometheus metrics and labels (name, version, category), or PostgreSQL tables and columns. Find more info and examples in the documentation folder.
- The TimescaleDB example dashboard requires some community plugins:
grafana-cli plugins install aidanmountford-html-panel
This repository includes a Dockerfile
, enabling you to easily build a docker container for this app, automatically installing all required dependincies while leaving your system unchanged.
git clone
this repository to your server- Build the container:
docker build -t alov/nexus-mods-stats .
- Run an exporter:
docker run -it -v /absolute/path/to/your/config.toml:/nm-stats/config.toml alov/nexus-mods-stats python ./timescaledb_exporter.py
Also included is a docker-compose.yml
, which allows you to automatically and easily deploy the whole stack of exporter, database and Grafana using docker.
git clone
this repository to your server- Edit
docker-compose.yml
to your needs (uncomment Prometheus or TimescaleDB) - If using Prometheus:
- Edit
documentation/prometheus.yml
if necessary, especially the scrape interval.
- Edit
- If using TimescaleDB:
- Create your services
docker-compose up --no-start
, but start only the PostgreSQL serverdocker start stats_timescaledb
. - Connect to your PostgreSQL server using
docker run -it --rm --network stats_default timescale/timescaledb:latest-pg9.6 psql -h stats_timescaledb -U postgres
and create your database (CREATE DATABASE "nm-stats";
).
- Create your services
- Set up your
config.toml
(instructions) - Deploy your stack:
docker-compose up -d
and access grafana athttp://localhost:3000
- If you have a domain and want your Grafana public facing with https, add a reverse proxy (e.g. nginx with letsencrypt). This can be done with docker, too: e.g. nginx-certbot, docker-letsencrypt.
Feel free to PR!