Docker Speedtest Grafana

This is a nice little application that is very straight-forward to install and get running.  After my previous videos on self hosted / open source speed tests you can run from a Web GUI, many of you asked about an option for getting multiple test results over time in order to track consistency of your internet speed performance.

I looked at several options, but I really liked this one that best.

What You'll Need

  • Git
  • Docker-CE
  • Docker-Compose
  • A text editor
  • About 10 minutes of your time

Installation

If you don't already have Docker and Docker-Compose setup, you'll want to get those installed. I have a script out on GitHub that will help you do that with ease.

You can just get the script with the command:

wget https://raw.githubusercontent.com/bmcgonag/docker_installs/main/install_docker_nproxyman.sh

This will pull down the script to your machine.  NOTE: this is a bash script, so you'll need a bash shell to run it (most Linux systems have bash by default).

Make the script executable with the command:

chmod +x install_docker_nproxyman.sh

Next, execute the script with the command

./install_docker_nproxyman.sh

You'll be prompted to select your OS, then asked what you want to install.  Simply answer "y" to any of the items you want installed.

Installing Docker Speedtest Grafana

Now, we want to pull down the Speedtest system.

Again, using git, we'll grab the entire repo with the command:

git clone https://github.com/frdmn/docker-speedtest-grafana

This will create a new folder called "docker-speedtest-grafana" in the directory you are currently in.

Now move into that new folder with:

cd docker-speedtest-grafana

Next, we need to copy the .env.sample file to a new .env file.

cp .env.sample .env

Now, we'll edit that file with a text editor. I like to use the nano editor, but feel free to use any text editor you like.

nano .env

You'll possibly want to change a couple of values in this file.

GRAFANA_PORT=3000
SPEEDTEST_SPEEDTEST_INTERVAL=3600
SPEEDTEST_HOST=local

If you have port 3000 already in use on your host machine, then you'll want to change the GRAFANA_PORT value to an unused port. I changed it to 3201 in my system.

Additionally, the speedtest is set to run one time per hour (or every 3600 seconds).  If you want to run the test more or less often, adjust the SPEEDTEST_SPEEDTEST_INTERVAL to a different time frame in seconds.

You can calculate the seconds as follows:

 1 minute = 60 seconds
 1 hour = 60 minutes = 3600 seconds

So if I want to run the ttest every 15 minutes, I do

15 x 60 = 900

And I enter 900 for my interval.

If you want to run the speedtest every 5 hours, you do

5 x 60 x 60 or 5 x 3600 =18000

and enter 18000 for the interval.

Once you've made those changes, use CTRL + O to save, and press Enter to confirm. Then, use CTRL + X to exit the nano editor.

Next, let's look at the docker-compose.yml file.

nano docker-compose.yml

version: '2'

services:
  influxdb:
    restart: always
    image: influxdb:1.8
    ports:
      - "8086:8086"
    volumes:
      - "./data/influxdb/:/var/lib/influxdb"
    environment:
      - "INFLUXDB_ADMIN_USER=admin"
      - "INFLUXDB_ADMIN_PASSWORD=password"
      - "INFLUXDB_DB=speedtest"

  grafana:
    restart: always
    image: grafana/grafana:6.7.2
    volumes:
      - "./docker/grafana/provisioning:/etc/grafana/provisioning"
    ports:
      - "${GRAFANA_PORT}:3000"
    environment:
      - "GF_SERVER_ROOT_URL=http://localhost"
      - "GF_SECURITY_ADMIN_PASSWORD=admin"
      - "GF_AUTH_ANONYMOUS_ENABLED=true"
    depends_on:
      - influxdb

  speedtest:
    restart: always
    image: frdmn/speedtest-grafana:latest
    container_name: speedtest
    environment:
      - "SPEEDTEST_INTERVAL=${SPEEDTEST_SPEEDTEST_INTERVAL}"
      - "SPEEDTEST_HOST=${SPEEDTEST_HOST}"
    depends_on:
      - influxdb

Here, I suggest making sure port 8086 is open on your host. If it's already in use, then change the left side of the port mapping under the influxdb section to an available port on your host.  Only change the left side of the colon ":".  Never change the right side in docker.

Save the changes. Use CTRL + O to save, and press Enter to confirm. Then, use CTRL + X to exit the nano editor.

Now, let's start up our containers with the command:

docker-compose up -d

Give the containers time to pull down, and startup.  Then when you see the "done" messages, and are back at your terminal prompt, open your web browser, and navigate to the IP address of your host machine, and the Port you set in the .env file.

In my case I went to http://192.168.10.26:3201

From there, in the Grafana UI, click on Home near the top left, then select the Speedtest option that comes up below it.

You should now see your speedtest dashboard.  It will take time to fill in, but eventually you should have a dashboard that shows you your speedtests over time.

Something like:

Speedtests after 1 night