Input JSON Array: json_time_format

I’m trying to get a json array inside my influxdb using telegraf. But have a problem to get the right time_format.

telegraf.conf:

[[inputs.file]]
   files = ["observations-export.json"]
   data_format = "json"
   json_query = "report"
   json_time_key = "time"
   json_time_format = "2006-01-02T15:04:05+02:00"

observation-export.json:

{  
  "report": [
        {
            "windspeed": 8,
            "windgust": 13,
            "winddirection": 116,
            "time": "2019-04-01T12:40:00+02:00"
        },
        {
            "windspeed": 10,
            "windgust": 15,
            "winddirection": 96,
            "time": "2019-04-01T12:50:00+02:00"
        },
        {
            "windspeed": 10,
            "windgust": 15,
            "winddirection": 110,
            "time": "2019-04-01T13:00:00+02:00"
        },
        {
            "windspeed": 10,
            "windgust": 13,
            "winddirection": 121,
            "time": "2019-04-01T13:10:00+02:00"
        }
    ]
}

When doing a test run with telegraf this is the output:

> file,host=server winddirection=116,windgust=13,windspeed=8 1554208800000000000
> file,host=server winddirection=96,windgust=15,windspeed=10 1554209400000000000
> file,host=server winddirection=110,windgust=15,windspeed=10 1554210000000000000
> file,host=server winddirection=121,windgust=13,windspeed=10 1554210600000000000

This is not the right epoch i think? So there is someting wrong changing from the time format to epoch.

Hi FutureCow , welcome back :slight_smile:

it is the right epoc , 1554208800 seconds = Tuesday, April 2, 2019 12:40:00 PM ,
but influx stores the timestamps in nanoseconds ( = 10−9 seconds ) hence
the nine extra zeroes … 1554208800000000000

Hello MarcV,

thank you for your answer. The problem isn’t the mili/nano seconds. But the time output. Like you see in the json file, the date should be the 1st of april, not the 2nd.

When I run telegraf now, this date:
2019-04-04T20:40:00+02:00
becomes:
1554237600000000000

wich is:
GMT : Tuesday 2 April 2019 20:40:00
Your time zone : dinsdag 2 april 2019 22:40:00 [GMT+02:00]

So this is not right, is there something wrong with my json_time_format?

Hi , it is not very clear … here is a discussion ,

Yep, already saw that discussion, tried some different things, but I doesn’t get the right epoch out of it…

I will try with your data …

Hi ,

i think it should be : json_time_format = “2006-01-02T15:04:05-07:00”

Yep i tried and it worked, thanks!