Skip to content
umputunPublic

About

Stats collector and reporter for RLB

Topics

Resources

Stars

7 stars

Watchers

5 watching

Forks

Repository files navigation

rlb-stats Build Status Coverage Status Go Report Card Docker Automated build

Stats collector for RLB with REST interface and WEB UI.

Run instructions

Run docker-compose up in order to start rlb-stats and rlb (for data generation).

Generate data

Run following command in the terminal in order to generate traffic for rlb-stats:

while true; do
  curl "http://127.0.0.1:7070/api/v1/jump/test1?url=/mp3files/test_file_$(((RANDOM % 10) + 1)).mp3" >/dev/null 2>&1
  sleep $(((RANDOM % 10) + 1))
done

API

Open http://127.0.0.1:8080/api/candle endpoint from to see all aggregated logs since the start of the container.

Dashboard

Open http://127.0.0.1:8080/ to see the dashboard. The dashboard is server-side rendered using HTMX, Picocss and ECharts and is embedded in the binary (the old SPA frontend from webapp/ has been removed). The dashboard requires internet access to load CSS and JavaScript libraries from cdn.jsdelivr.net. It provides:

  • Summary cards showing total downloads for 1 hour, 24 hours, 1 week, 1 month and all time
  • Downloads histogram (ECharts bar chart) with selectable time periods (1h, 12h, 24h, 10d, 30d, all)
  • Top downloaded files with visual bars
  • Per-node download statistics
  • Peak hours heatmap (24h x 7 days)

Period switching is handled via HTMX without full page reloads. Dark mode is supported automatically via Picocss.

The UI is compiled into the binary, so no files are needed on disk. To alter it without rebuilding, put a copy of app/web/templates and app/web/static into a directory and point --webapp at it, for example docker run -v ./my-ui:/srv/webapp ..., since the container's default is /srv/webapp. Each subdirectory is optional: static files fall back to the embedded copy one by one, and the templates are taken from the directory only if the whole set parses, since they reference each other. Symlinks leading out of the directory are not followed.

Application parameters

Command line Environment Default Description
port PORT 8080 Web server port
bolt BOLT_FILE /tmp/rlb-stats.bd boltdb file path
webapp WEBAPP webapp directory overriding the embedded UI, used if present
dbg DEBUG false debug mode
TIME_ZONE America/Chicago container timezone

API

Load candles

GET /api/candle, parameters - ?from=<RFC3339_date>&to=<RFC3339_date>&aggregate=<duration>

Retrieve candles from storage.

  • from (required) is the beginning of the interval, format is RFC3339, for example 2006-01-02T15:04:05+07:00
  • to (optional) is the end of the interval
  • max_points (optional, default 100) unsigned integer, sets aggregate interval to return not more than specified amount of candles; ignored when aggregate is set
  • aggregate (optional, overwrites max_points) is the aggregation interval (must be positive, truncated to minute), format examples are 5m, 600s, 1h

POST /api/insert

Insert LogRecord to storage. Expects LogRecord as a body:

{
	"from_ip": "172.21.0.1",
	"ts": "2021-03-24T08:20:00Z",
	"file_name": "rtfiles/rt_podcast659.mp3",
	"dest": "n3.radio-t.com"
}

About

Stats collector and reporter for RLB

Topics

Resources

Stars

7 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages