Write.points & JSON

I am trying to use a script (link) to write speedtest data to Influx. It is using write.point with JSON data. No data is ever written to the DB nor do I ever get an error of any kind.

print(‘Written To Influx: {}’.format(json_data)) yields the following:

[{‘measurement’: ‘speed_test_results’, ‘fields’: {‘download’: 132387121.40429239, ‘upload’: 11520874.192573223, ‘ping’: 16.774}, ‘tags’: {‘server’: ‘Spectrum’}}]

As far as I can tell the JSON is formatted correctly.

self.influx_client.write_points(json_data) just seems to do nothing.

Here are the versions I am running
Python 3.6.5
InfluxDB 1.5.3
speedtest-cli 2.0.2
influxdb python client 5.0.0

From what I can see you’re missing a timestamp.

Maybe do the following in your code:

import datetime
input_points = [
        {
            'measurement': 'speed_test_results',
            'fields': {
                'download': result_dict['download'],
                'upload': result_dict['upload'],
                'ping': result_dict['server']['latency']
            },
            'tags': {
                'server': result_dict['server']['sponsor']
            },
            'time': datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%SZ')
        }
    ]

It doesn’t seem to like that syntax.

File “InfluxdbSpeedtest.py”, line 110
‘time’: datetime.datetime.now().strftime(’%Y-%m-%dT%H:%M:%SZ’)
^
SyntaxError: invalid syntax

I forgot a comma. Edited my post to reflect the change.