Help with multi line csv


I have a multi line csv file and I’m struggling with the parsing.

This is how the csv looks like separated by ,

In a query I want to select all or specified disks and next to it show the status or the other way around, selecting the status for example 1 and show all the disks which have status 1.

Is there anyone who could help me?

Thanks in advance,

@Csupi003 I’m not really sure if I see the issue but what happens if you use the CSV parser by adding

  data_format = "csv"
  csv_header_row_count = 1
  csv_tag_columns = ["disk"]

to your input plugin? If I save your example to file and parse it with the above I get

> file,disk=1E:1:1,host=pop-os name="ssacli",status=1i 1690368726000000000
> file,disk=1E:1:2,host=pop-os name="ssacli",status=1i 1690368726000000000
> file,disk=1I:1:1,host=pop-os name="ssacli",status=1i 1690368726000000000
> file,disk=1I:1:24,host=pop-os name="ssacli",status=0i 1690368726000000000
> file,disk=1I:1:25,host=pop-os name="ssacli",status=2i 1690368726000000000

@srebhan Yes it does work in one way, it’s possible that I tried different configs in the same buckets because I definitely tried your config as well.

How could I select status as well? So in Influx query I select for example status: 1 and it would list only the disks with the status 1.

Otherwise it’s working great, Grafana now accepts it so thanks a lot!

Well the biggest issue is that if you make “status” a tag (by adding it to csv_tag_columns) , you only have the “name” (which probably also is a tag) as value. Please remember, Telegraf will drop metrics without a value…

This being said, I’d filter the status at query time (which is a InfluxQL or flux question) instead of poking around with the fields in Telegraf.

Got it, thanks a lot for the explanation.

1 Like