How to set epoch in influxdb-java?


#1

Hello.
I would like to return epoch time(ms) long in the java query instead of the default string rfc3339 but I don’t see a way on the java client even through OkHttpClient since HttpUrl is not used. I am using the latest influxdb-java 2.9.

Any pointers highly appreciated. Thank you!


#2

The return epoch time is determined by the query to the Influx API. You’ll have to forgive me for now being overly familiar with the java client, but I know that to change the epoch in the API, you would have to write something this:
http://127.0.0.1:8086/query?pretty=true --data-urlencode "db=telegraf" --data-urlencode "q=SELECT * FROM cpu limit 1" --data-urlencode "epoch=ms" {

Try adding the epoch option to your query and see if that helps.