Monitoring the Internet Bandwidth Quality of Service is essential to gain confidence in the service provider.
There are several solutions available for enterprise-scale bandwidth monitoring. This article is focused on a solution for home users. It is quick and straightforward. No coding is required.
In 2018, I worked on a pet project that involved setting up a monitoring system for my internet bandwidth. I used a Raspberry Pi and installed all the necessary software. However, one of my biggest challenges was accessing the dashboard outside my home network. It was complex, and I had to rely on local/on-prem environments. After thinking, I realized that leveraging cloud services could help me overcome this bottleneck. I'm excited to explore this idea further and see how it can improve my project.
- Needs the ability to access the monitoring dashboard from anywhere, so it should be hosted on a cloud service.
- Needs the ability to run an agent on the network to monitor 24x7, so a lightweight computer like Rasberry Pi will work.
Software components
- Docker standalone/local/on-prem runtime: To run the Telegraf agent container that collects the stats like download, upload, etc., and pushes them to a time-series database.
- InfluxDB Cloud instance: Cloud-based time series database to collect and store the internet speed stats
- Grafana Cloud instance: Cloud-based visualization instance to plot beautiful graphs of the internet speed.
Hardware components
- Raspberry Pi is connected to the home network and set up to run forever. Don't worry; its power consumption is very minimal.
Setup
- Login to the Influx DB Cloud portal with your Google account https://cloud2.influxdata.com/signup
- Setup "Company" and "Organization" You can give any name
- Create a "Bucket" - Imagin this to be a store
- We would use the Telegraf agent, so move to the Telegraf tab and create a configuration.
- Select the bucket you created earlier, and from the filter type "Internet Speed" select the tile.
- The above steps are going to create a Telegraf config file and provide instructions that are important to note down.
- INFLUX_TOKEN is required for the Telegraf agent to successfully write data into the cloud Influx DB
- The start command of Telegraf provides the reference path for the config file.
- Download Telegraf agent https://portal.influxdata.com/downloads/. There are several types, but we would be using the docker image.
- On the Raspberry Pi, install Docker and open a terminal.
- run the commands provided in the above link
# Debian-based imagedocker pull telegraf
- Start the container
docker run -e INFLUX_TOKEN=<Token> -p 8086:8086 -d -it --name telegraf telegraf --config https://<URL>
The above command is going to start the container with the config file location provided as https URL and start pushing the internet speed stats to the influx bucket
- Verify data in the Influx bucket
- Navigate to the influx Buckets tab and click on the bucket you created
- Select the measurement drop-down and select the internet_speed that you already created
- Select the fields and write a simple query to inspect the data that is collected
- This data is pushed from the Raspberry Pi on your home network
- Configure Grafana visualization
- Log into the Grafana Cloud portal https://grafana.com/auth/sign-in and launch the Grafana Cloud instance.
- We need to pull the data from Influx Cloud Bucket and plot the visualization to create the Influx data source.
- In the URL, use the influx cloud server URL, select Basic Authentication, and provide your login credentials.
- Provide the influx organization you created earlier and select the bucket you created earlier.
- This setup needs an Influx token to access the data from Grafana. So open the Influx Cloud instance and configure an API token with full access.
- Copy the token and use that in the Grafana Data Source config
- Now test the connection, and you should see that all is good
- Configre Grafana Dashboard
- Click Grafana >> Dashboard and New
- Select a pane and open the configuration
- Make sure the Time series is selected on the top-right
- Select the Data Source that you just created
- Now the challenge here is to write a Flux Language Query. It took some learning for me so I am providing a basic query that you can use and modify (refer: https://docs.influxdata.com/influxdb/v2.7/query-data/get-started/query-influxdb/)
- from(bucket: "Internet_mon")|> range(start: -30d)|> drop(columns: ["tag", "host", "server_id", "source"])|> filter(fn: (r) => r._measurement == "internet_speed" )|> filter(fn: (r) => r._field == "download")|> yield(name: "DownloadSpeed")
- The visualization starts showing the data
- Set alerts using the "Threshold" concept in Grafana - Whenever the internet download speed drops or disconnects, you would like to get an email/tweet.
- If the downtime continues for more than a threshold amount of time, say, 10 minutes or more, you should send an email to your service provided with detailed logs.