Cannot read data properly in line protocol


I would like to ask for help.

I want to read data from file using Telegraf.
That files are in line protocol:

meas,host=host1 Value=10 1632725859000000000

Telegraf writes data to Influx database.

When I’m logged in a influxdb web interface, I can see _measurement. When i click I can see in second tab _field, but when I click ‘Value’ in field I cannot see any hosts.

Similar situation is when I change ‘_field’ to host by drop-down list. In _measurement I can see host, but this host cannot see _fields.

It looks a little bit like _measurement has access to _field and host and ‘host’ has no access to _field and vice versa.

Thanks in advance for help.

Hello @Patryk,
Yes InfluxDB structures the output of data written to InfluxDB a differently than relational DBs. That line would produce the following table:

_measurement, _start, _stop, _time,                               _field, _value, _host
meas.               <start> <stop> 1632725859000000000 Value  10         host1

If your query looked like:

from(bucket: "<mybucket>")
|> range(start: <start>, stop: <stop>) 

host is a tag in your line protocol and value is a field. Fields keys and field values are split into two columns. Tag keys are given their own column and tag values are contained in the tag key column.
You don’t have access to other values across fields or tags because they’re different data elements.

Actually, any query doesn’t work.

When I run:
telegraf -config /etc/telegraf/telegraf.conf --test


telegraf -config /etc/telegraf/telegraf.conf --debug

Everything works properly, I have no errors.

To this bucket I also add Rest API in json format, which is in the same format and it’s written to Bucket:

exec,host=example1 Result_0=10, Result_1=10 1632899183000000000

When I choose ‘records’ from list, it looks like bellow:

I’m new influxdb user and if I understood your answer correct, I would need to have more details in that line protocol, but I don’t understand why in almost the same situation It works properly.

With the host it looks the same

Hello @Patryk,
The line protocol you shared:
exec,host=example1 Result_0=10, Result_1=10 1632899183000000000
would produce a write errror:
Failed to write data invalid write protocol submitted
Because there is space in between your field values. This is correct:
exec,host=example1 Result_0=10,Result_1=10 1632899183000000000

I don’t know if that’s a cause for any of your problems.

What do you mean by almost the same situation it works properly? What do you mean with the host it looks the same?

Tag keys might not be populating because you might not have written a tag (tags are optional).

Can you switch to the Script Builder and try:

from(bucket: "<mybucket>")
|> range(start: 0) 

This will allow you to query for all of your data.

I might also recommend reading the following key concepts to understand the InfluxDB data elements better and how they relate to line protocol and Flux:

It might also help to understand that InfluxDB’s input data format is different that InfluxDB’s output format:


I"m sorry. In this example I made a mistake. This line protocol which I shared has no space between field. I meant, the situation is the same, because In this exampe:

exec,host=example1 Result_0=10,Result_1=10 1632899183000000000

I read this ine protocol from Rest API which is JSON file. It looks almost the same like this:

meas,host=host1 Value=10 1632725859000000000

Only difference is that this second line protocol is read from the file.
And as I said, when I run “telegraf test” and “telegraf debug” I see no errors.
But when I try to get datas in influxdb, I see no data.

I do not understand why It did not work, because the line protocol “created” from API and read from file are almost the same.

However, thanks for any help :slight_smile:

I also tried to write this data:

meas,host=host1 Value=10 1632725859000000000

from file, by using this command:

influx write -o my_org -b test-bucket -t my_token /home/result1.flux

It also did not work properly although line protocol format seams to be ok.

Thanks for help, I’ve found solution.

your first post should tell me everything.

The problem is with API which creates ‘too old’ timestamps.