Adventures in IT

Running a docker #Syncthing relay (which I might describe in another post) gives interesting stats about the usage of your relay... but it's in JSON so no scraping with #Prometheus for visualisation in #Grafana.

The data

You can view your data by browsing to the IP of your docker, http://DOCKERIP:22070/status This gives the following data { "bytesProxied": 395065732238, "goArch": "amd64", "goMaxProcs": 4, "goNumRoutine": 557, "goOS": "linux", "goVersion": "go1.9.3", "kbps10s1m5m15m30m60m": [ 0, 27, 162, 1302, 697, 2428 ], "numActiveSessions": 10, "numConnections": 257, "numPendingSessionKeys": 0, "numProxies": 19, "options": { "global-rate": 0, "message-timeout": 60, "network-timeout": 120, "per-session-rate": 0, "ping-interval": 60, "pools": [ "" ], "provided-by": "XXXX" }, "startTime": "2020-09-02T18:40:24.868619628+02:00", "uptimeSeconds": 767343 } Especially the sessions and kbps data is interesting to follow.


How to get this data in #Influx? inputs.file input to the rescue. Simply add this to your telegraf.conf file (probably in /etc/telegraf). We'll output the JSON to /tmp as this data is not very relevant and to limit write/read actions on your storage (such as my #DietPi emmc)

[[inputs.file]] files = ["/tmp/syncthing"] name_override = "syncthing_relay" data_format = "json"

Create the JSON

Then, make a simple curl call to get the file on your system so we can read it. This needs to be added to a cron script afterwards. Do crontab -e to edit your cron profile and add:

*/1 * * * * curl http://DOCKERIP:22070/status -o /tmp/syncthing >/dev/null 2>&1

The file gets updated every minute by cron, telegraf reads it and stores in Influx. Next up... Visualisation in Grafana.

Grafana Dashboard for Syncthing Relay

Just make a new dashboard and import this JSON. You'll have to adapt your influx source to make it work.

You can download the JSON [here] (