Telegraf - input tail plugin error (Error: metric parse error: expected field at offset)

6.7k Views Asked by At

I want to read a plain text file. For this I use Tail Input Plugin. The configuration file is this:

[[inputs.tail]]
files = 
["/home/nikitalipatov/Programing/Projects/Diploma/TestData/test.txt"]
from_beginning = true
data_format = "influx"

[[outputs.file]]
files = ["stdout", 
"/home/nikitalipatov/Programing/Projects/Diploma/TestData/log.text"]
data_format = "influx"

Contents of the text file:

data1
data2
data3

But when I try to start Telegraf, I get this kind of error:

telegraf[14541]: 2018-05-16T16:46:24Z E! Error in plugin [inputs.tail]: E! Malformed log line in /home/nikitalipatov/Programing/Projects/Diploma/TestData/1.txt: [data1], Error: metric parse error: expected field at offset 5: "data1\n"
1

There are 1 best solutions below

0
On

The error is telling you what's wrong. That text file does not contain valid InfluxDB Line protocol for data. You have specified the data format as "influx" which means line protocol, so your data needs to conform to Line Protocol format.

measurement,tag=value value=data1,value=data2 timestamp

If you conform your data to that format, your data should load.

Best regards, dg