python influxdbclient - how to set precision to seconds?

2.1k views Asked by At

I am writing data point to influxdb database, for grafana to display. I have source datapoint time in epoch seconds.

Grafana displays the point, but the time on the graph is set as 1970. I suspect its the problem with precision cause grafana uses nanoseconds by default. I tried setting the precision as seconds with

from influxdb import InfluxDBClient


client.write_points(entry, params={'epoch': 's'})

but it yields error:

  client.write_points(entry, params={'epoch': 's'})
TypeError: write_points() got an unexpected keyword argument 'params'
1

There are 1 answers

0
Wojtas.Zet On

If you want to set precision to seconds

client.write_points(entry, time_precision='s')

does the trick.