frdmn / docker-speedtest-grafana

🚢📦Grafana + InfluxDB + Speedtest.net results
MIT License
206 stars 71 forks source link

[Feature Request] - Enhancements to data logging and structure #13

Open n1nj4888 opened 3 years ago

n1nj4888 commented 3 years ago

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!

frdmn commented 3 years ago

Thanks for the feature request!

1) Haven't thought about using a single measurement for this, to be honest. I have not that much experience with InfluxDB. I assume this would be a breaking change as well?

2) I saw that there is much more information in the JSON output but, as stated above - not sure how to properly store it in the database. Are you maybe able to contribute to the two points here? I don't mind breaking changes, as long as they are clearly listed a in the release notes.

3) Good point! I also do not really like that people are currently encouraged to use the included compose file (with its .env requirement). Maybe we could use the rename to also tidy up a bit the repo structure. Do you have an idea for a better name?

n1nj4888 commented 3 years ago
  1. Good point! I also do not really like that people are currently encouraged to use the included compose file (with its .env requirement). Maybe we could use the rename to also tidy up a bit the repo structure. Do you have an idea for a better name?

I'd call it "docker-speedtest-influxdb-logger" or something like that as InfluxDB is required (although can be provided externally), but grafana itself is not a mandatory requirement (other external, or no visualisation tools at all could be used)?

Alternatively you could call it "docker-speedtest-cli" and make the logging to InfluxDB as optional via an environment variable i.e. the docker container could be run without influx and simply log to the console/file?

Thanks!