Timestamp in result different than in source file

Windows Server 2019
InfluxDB 2.0.8
Telegraf 1.20.0-rc0

telegraf.conf:

[[inputs.file]]
files = ["C:/example.xml"]
data_format = "xml"

[[inputs.file.xpath]]

metric_name = "string('Example')"
timestamp = "concat(substring(/Report/StartTime, 7, 4), '-', substring(/Report/StartTime, 1, 2), '-', substring(/Report/StartTime, 4, 2), 'T', substring(/Report/StartTime, 12, 2), ':', substring(/Report/StartTime, 15, 2), ':', substring(/Report/StartTime, 18, 2))" 
timestamp_format = "2006-01-02T15:04:05"

[inputs.file.xpath.tags]

[inputs.file.xpath.fields_int]

[inputs.file.xpath.fields]
example = "number(/Report/Values/valueA)"

example.xml:

<?xml?>
<Report>
  <StartTime>09/15/2021 07:00:00</StartTime>
  <Values>
    <valueA>410.66</valueA>
  </Values>
</Report>

Result in Data Explorer:
,0,2021-09-15T05:28:58.7649082Z,2021-09-15T11:28:58.7649082Z,2021-09-15T07:01:00Z,410.66,example,Example

How on earth do I end up with 7:01:00 as a result having 7:00:00 in xml file? :exploding_head:

To me looks like the timestamp you are getting is the actual insert timestamp, I’ve tried your example and it works correctly.

if I run the command: .\telegraf.exe --config .\telegraf.conf --test
I get this lineprotocol output:
Example,host=QDLP03 example=410.66 1631689200000000000

If I translate it back to a readable date (always using powerhsell)

$origin = New-Object -Type DateTime -ArgumentList 1970, 1, 1, 0, 0, 0, 0
$unixTimeNano = 1631689200000000000
$divToMilli = 1000000
$origin.AddMilliseconds($unixTimeNano/$divToMilli)

I get exactly what I was expecting “Wednesday, September 15, 2021 7:00:00 AM”

I have no idea why It behaves like this, look like it’s ignoring the provided timestamp completely.
I had a look around and didn’t find any issue that sounds like this one.

@Anaisdg do you have any idea?

I’ve figured it out.
In window period “auto” setting was messing the output visible in Data Explorer.
image

Anyhow, many thanks for committing your time to look into it.

1 Like