Telegraf tail input file encoding?


i am trying to use Telegraf to tail a log file that i create with line protocol on windows.

I am getting the following:

2017-06-09T12:19:50Z E! Error in plugin [inputs.tail]: E! Malformed log line in C:\Shared\test\ConsoleApp4.log: 
[performance,machine=xxx latency=570 1497010790194715300
], Error:  metric parsing error, reason: [invalid timestamp], buffer: [performance,machine=xxx latency=570 

although it looks like a valid line protocol entry.
I have dig a little deeper and found a check in metric/parse.go

if buf[i] < '0' || buf[i] > '9' {
     return i, buf[start:i], makeError("invalid timestamp", buf, i)

which check that the char in buf is between 0 and 9.
my buf entries are not in that range leading me to belief that it is a encoding issue.
my file is UTF-8 (windows).

Can i instruct Telegraf to use this encoding, if that is the issue?


@mantzas I think this might have to do with the timestamp precision? It looks like it’s in microseconds? Can you try adding some 000s to make it nanoseconds? @daniel might be able to help you on the UTF-8 thing.

Just a guess, but maybe we don’t handle windows line endings correctly. Can you try to convert the file to unix line endings and see if that fixes the problem?

@jackzampolin i took a look into telegraf’s code. it is expected to be 19 chars. Converting .net DateTime.Ticks to ns is just a multiplication with 100.
@daniel i have debugged until i hit the above code. the buffer contains invalid characters based on the if statement. I will try to convert the file to UNIX line endings and i will try again on Monday.

I will get back to you on Monday with feedback. Have a nice weekend!

1 Like

@daniel @jackzampolin i just converted the line endings to UNIX ones and it seemed to work. Now the problem is that the logging library does not support UNIX line endings and changing the library is not a small task. Could we fix telegraf? Should i open a github ticket?

@mantzas Please open an issue on telegraf. Thank you for the report!

done issue