Maavey / lancache-stats

LanCache Dashboard
GNU General Public License v3.0
6 stars 3 forks source link

LanCache Dashboard

Collect, Parse and send logs to MySQL database to process it into an awesome dashboard.

Originally inspired by lancache-elk, but I found it too resource hungry for my needs, couldn't find a light alternative, so I decided to make a simple alternative.

Requirements

Setup

Data collection

  1. Execute lancache_db.sql on the mysql database.

  2. Put sendlogs.sh on the LanCache docker host and edit the parameters to fit your setup.

  3. Edit the log format of the lancache-data container so it is easier to parse

    1. sudo docker exec -it [dockerid] bash
    2. If nano is not available yet, install it: apt-get install nano
    3. nano /etc/nginx/conf.d/10_log_format.conf
    4. Edit log_format cachelog to log_format cachelog '[$time_local] $cacheidentifier $upstream_cache_status $remote_addr $status $body_bytes_sent "$request_uri" "$http_referer" "$http_user_agent" "$host" "$http_range"';
    5. Exit and save (CTRL + X), Y.
    6. This edit is automatically picked up, but not persisted to a volume and will be lost when the container is recreated.
  4. Create a CronJob to call sendlogs.sh at your desired interval. We recommend a 1 minute interval.

    1. Make sure the script is executable chmod +x ./sendlogs.sh
    2. With the user that is able to access the sendlogs.sh and LanCache logs: crontab -e
    3. Add job entry, every minute is the fastest we can go: * * * * * /path/to/sendlogs.sh
    4. Save and exit

Dashboard using PHP

  1. On the LAMP server, copy dashboard.php and conn.php.new to the desired web folder.

  2. Edit conn.php.new with the database information and store or rename it as conn.php

PHP Dashboard Screenshot

Dashboard using Grafana

  1. Connect the lancache-stats DB to your Grafana.
  2. Import grafana_dashboard.json into your grafana instance. The database name used for this dashboard was lancache_db, and may need to be changed for your setup.

Grafana Dashboard Screenshot

Supported functionality

To Do

Buy me a Coffee?