Keep track of your internet connection speeds over time with a Raspberry Pi.
This Helm chart deploys:
- InfluxDB 2.x database for time series data.
- Grafana dashboard.
- Python app to run the speed test on a schedule.
- Set up your Raspberry Pi.
- Install and configure MicroK8s (or another lightweight Kubernetes distribution with DNS and Helm addons) on your Pi.
Note: MicroK8s by default uses Dqlite
as its storage backend instead of etcd
. Further securing of Secret
objects with encryption at rest for either storage backend is outside the scope of this project.
-
Prepare your Raspberry Pi's local storage for both the database and dashboard
# On your Pi sudo mkdir -p /var/lib/influxdb2 sudo mkdir -p /etc/influxdb2 sudo mkdir -p /var/lib/grafana
-
If installing from the repository
# On your Pi helm repo add santisbon https://santisbon.github.io/charts/ # or helm repo update CHART="santisbon/speedtest"
Or if installing from source
# On your Pi git clone https://github.com/santisbon/speedtest.git && cd speedtest CHART="./speedtestchart" nano $CHART/values.yaml # edit the values
-
Install the Helm chart which will enforce the installation order. Set parameters like the schedule to run the test if you didn't do it through the
values.yaml
file.
If using MicroK8s add it to the typed commands e.g.microk8s helm
,microk8s kubectl
.# On your Pi RELEASE=speedtest NAMESPACE=speedtest-n helm install $RELEASE $CHART \ -n $NAMESPACE \ --create-namespace \ --set nodeHostname=raspberrypi4 \ --set influxdbpassword=supersecret \ --set influxdbtoken=my-super-secret-auth-token \ --set schedule="*/10 * * * *"
-
Grab the
NodePort
assigned to the Grafana service (by default in the 30000-32767 range).# On your Pi kubectl -n $NAMESPACE get svc $RELEASE-grafana-svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE speedtest-grafana-svc NodePort 10.152.182.171 <none> 3000:32425/TCP 52s
In this example it's 32425.
-
From your desktop, access the Grafana dashboard using your Raspberry Pi's IP address or DNS name and the
NodePort
from the previous step e.g. http://raspberrypi4.local:32425. The default credentials are admin/admin. -
Add a new connection with data source InfluxDB.
- Set query language to Flux.
- Set the URL using your Helm release name and InfluxDB port e.g. http://speedtest-influxdb-svc:8086.
- Use the organization, token, and bucket you set in
values.yaml
or the command line. If you didn't set a token, one was created for you. You can retrieve it from a shell in theinfluxdb-c
container with the commandinflux auth list
. - Click on Save & Test.
- Build a dashboard and add a visualization (panel) with the data source you created.
- Write the Flux queries you want for your visualizations filtering by
_measurement
or_field
. Some examples:speeds = from(bucket: "internetspeed") |> range(start: -1d) |> filter(fn: (r) => r._field == "download" or r._field == "upload") |> yield(name: "_results") latency = from(bucket: "internetspeed") |> range(start: -1d) |> filter(fn: (r) => r._field == "ping" or r._field == "jitter") |> yield(name: "_results")
- Save your dashboard. You can add multiple panels and set units like megabits per second (Mbps) and ms. The units are in the Standard options section of the panel.
helm upgrade $RELEASE $CHART -n $NAMESPACE
helm uninstall $RELEASE -n $NAMESPACE --wait
kubectl delete namespaces $NAMESPACE