Giter VIP home page Giter VIP logo

docker-speedtest-grafana's Introduction

docker-speedtest-grafana

Docker setup consisting out of Grafana incl. a pre-configured dashboard, InfluxDB and a speedtest.net CLI test runner.

Installation

  1. Make sure you've installed all requirements
  2. Clone this repository:
git clone https://github.com/frdmn/docker-speedtest-grafana
  1. Create a copy of the sample .env file and adjust it at will:
cp .env.sample .env
  1. Spin up the containers:
docker-compose up -d

Configuration

You can make use of the following environment variables / configurations:

Environment variable Default value Description
GRAFANA_PORT 3000 Port to bind Grafana webinterface on the host system
SPEEDTEST_SPEEDTEST_INTERVAL 3600 Interval/pause (in seconds) between speedtests
SPEEDTEST_HOST local Display name of the client
SPEEDTEST_SERVER none Optionally set specific speedtest.net server ID, otherwise use the closest
INFLUXDB_DB speedtest Database to save speedtest results
INFLUXDB_HOST influxdb Name of the InfluxDB host/containers
INFLUXDB_USERNAME root Username for InfluxDB authentication
INFLUXDB_PASSWORD root Password for InfluxDB authentication

Usage

Services

Start/create services

$ docker-compose up -d
Creating speedtest_influxdb_1  ... done
Creating speedtest_grafana_1   ... done
Creating speedtest_speedtest_1 ... done

Stop services

$ docker-compose stop
Stopping speedtest_influxdb_1  ... done
Stopping speedtest_grafana_1   ... done
Stopping speedtest_speedtest_1 ... done

Upgrade services

$ docker-compose stop
$ docker-compose pull
$ docker-compose rm
$ docker-compose up -d

Check logs

$ docker-compose logs -f
$ docker-compose logs -f grafana

Grafana

Dashboard

By default the dashboard shows all speedtest results. To filter for a specifc host, simply add a and host = 'local' statement in the WHERE clause of the SQL select.

Example (Download Time Serie):

SELECT mean("value") FROM "download" WHERE $timeFilter and host = 'local' GROUP BY time($interval) fill(null)

Administrative access

Access http://${HOSTNAME}:${GRAFANA_PORT} (http://localhost:3000 by default) and login using the following default credentials:

  • Username: admin
  • Password: admin

Contributing

  1. Fork it
  2. Create your feature branch:
git checkout -b feature/my-new-feature
  1. Commit your changes:
git commit -am 'Add some feature'
  1. Push to the branch:
git push origin feature/my-new-feature
  1. Submit a pull request

Requirements / Dependencies

  • Docker (incl. docker-compose)

Version

1.0.0

License

MIT

docker-speedtest-grafana's People

Contributors

crazyuploader avatar d3473r avatar frdmn avatar karloskalcium avatar therealshark avatar yourit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-speedtest-grafana's Issues

What are the requirements?

The first step is make sure you've installed all requirements. What are those requirements? I've saw a similar project on git and it had most things explained step by step. Can someone add some detail as to what the requirements are?

Raspberry Pi grafana issue

Trying to get this running on a raspberry pi fails due to what I suspect to be the wrong grafana version:
grafana | standard_init_linux.go:211: exec user process caused "exec format error" grafana exited with code 1

I'm a bit new to this and am working on solving it but not getting terribly far.

Email Alerts - Missing grafana.ini file

Hi, I have installed and set up the Grafana Dashboard and it works fine.
I would like to add email alerts and in order to do this, I need to edit the grafana.ini file. However, this file does not exist with this install. I have checked all the folders and I cannot find the file.

image

I have spent hours googling and trying to find how to resolve it.
Please can someone help with my issue?

Thanks in advance.

Works fine on a RPi 4 for weeks, then ceases to function

I got this to run on a rpi4 with a modified docker-compose.yml, just needed to build the "speedtest" container on the rpi4 instead of pulling it from the repository to make it work.

Now I observe the following problem:
After some days/weeks, the speedtest container stops adding new data to the influxdb. In the logs I can see the speedtest container restart due to the node index.js command exiting with some error related to name resolution. No problem with that, shit happens, maybe network is temporarily down for some reason etc..

The "speedtest" container is then automatically restarted as it should be, but does not continue doing its job of performing speed tests, I cant figure out why... docker-compose down + docker-compose up fixes it.

I think the problem is connected to the SIGTERM, see the log below. This happens in the first iteration after the container is restarted.

Any ideas?

speedtest    | [INFO][Fri Jan 22 2021 17:12:48 GMT+0000 (Coordinated Universal Time)] Starting speedtest...
speedtest    | [INFO][Fri Jan 22 2021 17:13:17 GMT+0000 (Coordinated Universal Time)] Speedtest results - Download: 19.204848000000002, Upload: 15.571952, Ping: 45.808
speedtest    | [INFO][Fri Jan 22 2021 17:13:17 GMT+0000 (Coordinated Universal Time)] Sleeping for 1800 seconds...
speedtest    | [INFO][Fri Jan 22 2021 17:43:17 GMT+0000 (Coordinated Universal Time)] Starting speedtest...
speedtest    | Command failed with exit code 2: speedtest --accept-license --accept-gdpr -f json
speedtest    | {"type":"log","timestamp":"2021-01-22T17:43:34Z","message":"Failed to resolve host name. Cancelling test suite.","level":"error"}
speedtest    | {"error":"Host resolve failed: Timeout occurred in connect."}
speedtest    | [INFO][Fri Jan 22 2021 17:43:36 GMT+0000 (Coordinated Universal Time)] Starting speedtest...
speedtest    | Command was killed with SIGTERM (Termination): speedtest --accept-license --accept-gdpr -f json
speedtest    | {"type":"log","timestamp":"2021-01-22T17:43:55Z","message":"Error: [11] Cannot read: Resource temporarily unavailable","level":"error"}

Feature request: Give option to select specific Speedtest server

Please consider giving option via envionment variable to run again specific target. One can pass speedtest server ID and then server tests against that.

Example of test against specific server:

docker run --rm moutten/speedtest-cli --list | grep Airtel | grep Mumbai
 2827) Bharti Airtel Ltd (Mumbai, India) [13.76 km]
19081) Airtel Broadband (Mumbai, India) [13.76 km]

This shows ID of the server - 2827 and 19081.

SPEEDTEST_SPEEDTEST_INTERVAL variable should be SPEEDTEST_INTERVAL?

Hi There,

The README lists one of the environment variables as SPEEDTEST_SPEEDTEST_INTERVAL but this is actually referenced in the code as SPEEDTEST_INTERVAL. the .env.sample and docker-compose.yml also reference this as SPEEDTEST_SPEEDTEST_INTERVAL and $SPEEDTEST_SPEEDTEST_INTERVAL but this should just be SPEEDTEST_INTERVAL?

Thanks!

502 error 53: connect: cannot assign requested address

Trying to use the docker-compose file as-is and the error I'm getting in the grafana container logs is:

grafana_1    | t=2021-03-01T19:06:09+0000 lvl=info msg="Request Completed" logger=context userId=0 orgId=1 uname= method=GET path=/api/datasources/proxy/1/query status=502 remote_addr=192.168.2.144 time_ms=1 size=0 referer="http://192.168.2.168:3020/d/0A6hxROiz/speedtest-results?orgId=1"

192.168.2.168 is my "docker machine" and 192.168.2.144 is my windows client which is accessing grafana via http://192.168.2.168:3020 (3020 is the port I specified for grafana)

Env file (not much changed)

GRAFANA_PORT=3020
SPEEDTEST_SPEEDTEST_INTERVAL=3600
SPEEDTEST_HOST=local

docker-compose file , should be same as master branch

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

Command failed with exit code 2:

Hi,

My speedtest doesn't seem to be running, but I have access to the Grafana gui.

I'm running this inside an LXC container based on the Turnkey Core image.

Logs below:

docker-compose logs -f speedtest
Attaching to speedtest
speedtest | [INFO][Wed Sep 09 2020 05:14:05 GMT+0000 (Coordinated Universal Time)] Starting speedtest...
speedtest | Command failed with exit code 2: speedtest --accept-license --accept-gdpr -f json
speedtest | [2020-09-09 05:14:05.252] [error] Configuration - SSL peer certificate or SSH remote key was not OK (UnknownException)
speedtest | [2020-09-09 05:14:05.252] [error] Configuration - Cannot retrieve configuration document (0)
speedtest | [2020-09-09 05:14:05.252] [error] ConfigurationError - Could not retrieve or read configuration (Configuration)
speedtest | [2020-09-09 05:14:05.253] [error] ConfigurationError - Could not retrieve or read configuration (Configuration)
speedtest | {"type":"log","timestamp":"2020-09-09T05:14:05Z","message":"Configuration - Could not retrieve or read configuration (ConfigurationError)","level":"error"}

influxdb error when installing

Here is the screenshot of what happens.
Installing on Synology, I have tried 50 different trys, But always get an influxdb error when installing
Help

Thank You
Maybe, You could make a Synology install package for this, Please ?

[Feature Request] - Enhancements to data logging and structure

Hi There,
Thanks for the great docker container for this! I have a couple of feature suggestions if I may?

(1) Currently the container writes 3 seperate measurements to Influx (upload, download and ping), when it would be better to write this as a single "speedtest" measurement with upload, download and ping results in a single row within InfluxDB. This way, you can get the download/upload/ping results obtained from a single speedtest measurement from one row in grafana (rather than 3 seperate queries across 3 seperate measurements)
(2) The JSON result from the speedtest command actually contains a lot more data that would also be great to log in the InfluxDB and could lead to much more analysis options such as data sent/received, logging the server that performed the speedtest, plotting results on a map using city/country etc .

The JSON returned by the speedtest command is as per below so I've also suggested how you may write these fields to Influx, again all as a single row in a "speedtest" or "results" measurement as per suggestion (1):

{
	"type":"result",
	"timestamp":<timestamp>,
	"ping":
	{
		"jitter":<ping.jitter>
		"latency":<ping.latency>
	},
	"download":
	{
		"bandwidth":<download.bandwith>
		"bytes":<download.bytes>
		"elapsed":<download.elapsed>
	},
	"upload":
	{
		"bandwidth":<upload.bandwith>
		"bytes":<upload.bytes>
		"elapsed":<upload.elapsed>
	},
	"packetLoss":<packetLoss>
	"isp":<isp>
	"interface":
	{
		"internalIp":<interface.internalIp>,
		"name":<interface.name>,
		"macAddr":<interface.macAddr>,
		"isVpn":<interface.isVpn>,
		"externalIp":<interface.externalIp>
	},
	"server":
	{
		"id":<server.id>,
		"name":<server.name>,
		"location":<server.location>,
		"country":<server.country>,
		"host":<server.host>,
		"port":<server.port>,
		"ip":<server.ip>
	},
	"result":
	{
		"id":<result.id>,
		"url":<result.url>
	}
}

Obviously the above would be "breaking changes" for any existing databases / grafana dashboards so perhaps the more extensive results above could be controlled with a "Verbose" environment variable? This would also enable users to select whether they want all the additional data or just the simple upload/download/ping results?

(3) A minor niggle but the current name of the image frdmn/docker-speedtest-grafana implies grafana is included/required but actually it isn't and the container can be run with an external grafana or indeed without grafana at all?

Thanks for your consideration!

[Feature Request] - Multiple Speedtest Servers

It would be nice if we could have a list of speedtest serverids that it would loop through rather than just relying on a single speedtest server for every test. I think a maximum of 3 would be great and having it move to the next serverid in the list each time it performs the test would give a better overall result than just hitting the same server every time.

No data on all widgets

I fixed the 502 error by changing the influxdb host to the IP of my device on the 'docker-speedtest-grafana/docker/grafana/provisioning/datasources/influxdb.yml' file. However, now all the widgets are showing me the "No data" message.

Could you please suggest some tests or troubleshooting steps in order to check why is happening this issue?

Thanks in advance.

error0

error1

Speed Test is showing incorrect values after a period of time/executions

Hello,

i am using this docker compose setup now since around 1 week.
what i noticed, and i can not figure out why this happens, is that the test results are matching my manual tests on the start of the containers.

but at some point, the docker tests are at around 100mbit/s, which is not matching my manual test in that moment then. (i use ookla for the manual test and downloading test files from my own dedicated server at hetzner in germany) both gives me a result of around 170mbit/s.

when i delete the entire container setup, and set it up from scratch, also the docker containers show this value again.

is there anything someone here has as an idea what goes wrong with my setup?

Kind regards
Gardosen

(Feature request) Test against multiple servers

Please consider adding a feature where we can define multiple speed test server and it tests against those sequentially. One can define the speed test server using the ID.

I would love to have a test report from a couple of servers in India, Europe, US and Singapore.

What do I use for SPEEDTEST_SERVER

I assume this means I can specify the speedtest.net host to use.
Where do I get the list of hostnames?
I would like to test against a particular host (Cleveland Broadband)

Specify run time

I want to run the test once a day in the middle of the night so I do not max out my connection for a test during the day when I may be working or streaming.

Is there a config to set the speed test to run at a specified time?

Getting the following error in our on premise datacenter (only IPv6 environment)

hi Team,

We are following error when we deploy the speedtest server. Any help would be much appreciated.

[INFO][Thu Jun 30 2022 10:56:46 GMT+0000 (Coordinated Universal Time)] Starting speedtest... Command failed with exit code 2: speedtest --accept-license --accept-gdpr -f json [2022-06-30 10:56:51.884] [error] Trying to get interface information on non-initialized socket. [2022-06-30 10:56:51.885] [error] Configuration - A requested feature, protocol or option was not found built-in in this libcurl due to a build-time decision. (UnknownException) [2022-06-30 10:56:51.885] [error] Configuration - Cannot retrieve configuration document (0) [2022-06-30 10:56:51.885] [error] ConfigurationError - Could not retrieve or read configuration (Configuration) [2022-06-30 10:56:51.886] [error] ConfigurationError - Could not retrieve or read configuration (Configuration) {"type":"log","timestamp":"2022-06-30T10:56:51Z","message":"Configuration - Could not retrieve or read configuration (ConfigurationError)","level":"error"}

Speedtest appears to prompt for licence acceptance often!

Speedtest appears to prompt for licence acceptance often!

speedtest | Command failed with exit code 2: speedtest --accept-license --accept-gdpr -f json
It looks like either my IP address has been blacklisted for excessive requests to speedtest-cli (My broadband is bad so I've been monitoring a lot over the last monitoring a lot lately)
Anyone got a solution for interpreting this JSON response and accepting the prompt?
My short term solution is to have a cron job stopping and starting the containers every 6 hours or so.
Thanks in advance!

[CR] add server,ip etc write to influxdb

i want to add more muliti segments like below server info,but now only support 2 segments, will support?

"server":{"id":3633,"name":"ChinaTelecom","location":"Shanghai","country":"China","host":"speedtest1.online.sh.cn","port":8080,"ip":"101.95.48.41"}`
/usr/src/app # /usr/bin/speedtest -f json
{"type":"result","timestamp":"2022-02-07T12:27:35Z","ping":{"jitter":0.14999999999999999,"latency":10.974},"download":{"bandwidth":115106257,"bytes":1397939096,"elapsed":12711},"upload":{"bandwidth":4362655,"bytes":60270168,"elapsed":12409},"isp":"China Telecom","interface":{"internalIp":"172.19.0.4","name":"eth0","macAddr":"02:42:AC:13:00:04","isVpn":false,"externalIp":"115.193.174.195"},"server":{"id":3633,"name":"China Telecom","location":"Shanghai","country":"China","host":"speedtest1.online.sh.cn","port":8080,"ip":"101.95.48.41"},"result":{"id":"ab44b5d4-2a04-43a7-912a-b77cee852890","url":"https://www.speedtest.net/result/c/ab44b5d4-2a04-43a7-912a-b77cee852890"}}
/usr/src/app # 

const getSpeedMetrics = async () => {
const args = (process.env.SPEEDTEST_SERVER) ?
[ "--accept-license", "--accept-gdpr", "-f", "json", "--server-id=" + process.env.SPEEDTEST_SERVER] :
[ "--accept-license", "--accept-gdpr", "-f", "json" ];

const { stdout } = await execa("speedtest", args);
const result = JSON.parse(stdout);
return {
upload: bitToMbps(result.upload.bandwidth),
download: bitToMbps(result.download.bandwidth),
server: result.server.name,
serverip: result.server.ip,
isp: result.isp,

ping: result.ping.latency
};
};

External InfluxDB / Grafana

Hi,

For those of us with existing InfluxDB and Grafana containers/services, Is it possible to run the Speedtest Docker image without creating new InfluxDB and grafana containers?

Looking at your docker-compose.yml it looks to create 3 separate containers for Speedtest, influx and grafana so can I assume that by only using “frdmn/speedtest-grafana“, the Speedtest would run on its own and if so, how to specify an existing external InfluxDB host/port/username/password/database to write to?

Thanks!

Add more SQL examples to README

upload and ping example

SELECT mean("value") FROM "upload" WHERE $timeFilter and host = 'local' GROUP BY time($interval) fill(null)
SELECT mean("value") FROM "ping" WHERE $timeFilter and host = 'local' GROUP BY time($interval) fill(null)

Add "How to change speedtest interval" to README

This is how docker-compose.yml looks like:

speedtest:
    restart: always
    image: frdmn/speedtest-grafana:latest
    container_name: speedtest
    environment:
      - "SPEEDTEST_INTERVAL=${SPEEDTEST_SPEEDTEST_INTERVAL}"
      - "SPEEDTEST_HOST=${SPEEDTEST_HOST}"
    depends_on:
      - influxdb
  1. Where does ${SPEEDTEST_SPEEDTEST_INTERVAL} come from? (.env file?)
  2. How can I change the values while running via docker-compose up? Is it possible to change the interval without stopping and deleting everything and (with edited .env file) starting from scratch?

Great work by the way
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.