Skip to content

Latest commit

 

History

History
71 lines (54 loc) · 4.47 KB

README.md

File metadata and controls

71 lines (54 loc) · 4.47 KB

Nexus Mods Stats

Collects and tracks various stats of your Nexus Mods mods.

Contents

  1. Installation
  2. Usage
  3. Installation and usage with Docker
  4. Constributing
  5. Screenshots

Installation

  1. git clone this repository to your server.
  2. 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) and pip install psycopg2
  3. Copy documentation/config.toml.example to config.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.
  4. 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!

Usage

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:

  1. Install Prometheus
  2. Run ./prometheus_exporter.py as a daemon.
  3. 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:

  1. Install PostgreSQL + TimescaleDB
  2. Depending on your setup, enable network-based access: listen_addresses in postgresql.conf, authentication in pg_hba.conf.
  3. Set up a user, password, and database (instructions). Add this configuration to your config.toml.
  4. Run ./timescale_exporter.py as a daemon.

To display metrics with Grafana:

  1. 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.
  2. The TimescaleDB example dashboard requires some community plugins: grafana-cli plugins install aidanmountford-html-panel

Installation and usage with Docker

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.

  1. git clone this repository to your server
  2. Build the container: docker build -t alov/nexus-mods-stats .
  3. 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.

  1. git clone this repository to your server
  2. Edit docker-compose.yml to your needs (uncomment Prometheus or TimescaleDB)
  3. If using Prometheus:
    1. Edit documentation/prometheus.yml if necessary, especially the scrape interval.
  4. If using TimescaleDB:
    1. Create your services docker-compose up --no-start, but start only the PostgreSQL server docker start stats_timescaledb.
    2. 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";).
  5. Set up your config.toml (instructions)
  6. Deploy your stack: docker-compose up -d and access grafana at http://localhost:3000
  7. 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.

Contributing

Feel free to PR!

Screenshots

Grafana dashboard showing stats of a single mod Grafana dashboard showing stats grand total