Speedtest-for-InfluxDB-and-Grafana icon indicating copy to clipboard operation
Speedtest-for-InfluxDB-and-Grafana copied to clipboard

Add additional fields/tags to write to InfluxDB

Open n1nj4888 opened this issue 4 years ago • 0 comments

Hi There.

Currently the following fields and tags are written to InfluxDB (InfluxdbSpeedtest.py)...

                'fields': {
                    'download': result_dict['download'],
                    'upload': result_dict['upload'],
                    'ping': result_dict['server']['latency'],
                    'server': result_dict['server']['id'],
                    'server_name': result_dict['server']['name']
                },
                'tags': {
                    'server': result_dict['server']['id'],
                    'server_name': result_dict['server']['name'],
                    'server_country': result_dict['server']['country']
                }

Could these be extended to include the full list as follows (i.e. these are already stored in the results_dict variable just not written to the influxDB)? There's quite a few extra ones here but some are key including "server_sponsor", "server_lat", "server_lon", "server_country" (as field) and the client details also...

Also - It would be good to be able to specify a "host" string (normally defaulted to "local") in the config.ini file which is written to InfluxDB as an additional tag. This way, multiple docker instances can be run with different "host" tags allowing them all to write to the same InfluxDB database/measurement but also able to be filtered by host tag.

                'fields': {
                    'download': result_dict['download'],
                    'upload': result_dict['upload'],
                    'ping': result_dict['server']['latency'],
                    'server': result_dict['server']['id'],
                    'server_name': result_dict['server']['name'],
                    'server_url': result_dict['server']['url'],
                    'server_lat': result_dict['server']['lat'],
                    'server_lon': result_dict['server']['lon'],
                    'server_country': result_dict['server']['country'],
                    'server_cc': result_dict['server']['cc'],
                    'server_sponsor': result_dict['server']['sponsor'],
                    'server_id': result_dict['server']['id'],
                    'server_host': result_dict['server']['host'],
                    'server_distance': result_dict['server']['d'],
                    'bytes_sent': result_dict['bytes_sent'],
                    'bytes_received': result_dict['bytes_received'],
                    'share': result_dict['share'],
                    'client_ip': result_dict['client']['ip'],
                    'client_lat': result_dict['client']['lat'],
                    'client_lon': result_dict['client']['lon'],
                    'client_isp': result_dict['client']['isp'],
                    'client_isprating': result_dict['client']['isprating'],
                    'client_rating': result_dict['client']['rating'],
                    'client_ispdlavg': result_dict['client']['ispdlavg'],
                    'client_ispulavg': result_dict['client']['ispulavg'],
                    'client_loggedin': result_dict['client']['loggedin'],
                    'client_country': result_dict['client']['country'],
                },
                'tags': {
                    'server': result_dict['server']['id'],
                    'server_name': result_dict['server']['name'],
                    'server_country': result_dict['server']['country'],
                    'host' <---- This would be a static variable that is read from the config.ini file that allows a specific tag to be able to be added to a specific instance (of the docker) so that grafana can be filtered by the host running the container/service
                }

Thanks!

n1nj4888 avatar Sep 06 '20 10:09 n1nj4888