I’m trying to write to Influx using Telegraf by writing lines of CSV which are picked up by using Python. I’m having trouble because the headers that I’m specifying don’t seem to be be being used when writing to the database.
Probably easiest if I explain with an example:
meter = "something"
col_1 = 1
col_2 = 2
col_3 = 3
col_4 = 4
message_1 = ("meter,col_1,col_2\r\n%s,%0i,%0i" % (meter,col_1,col_2))
reporter.send_data(message_1)
message_2 = ("meter,col_3,col_4\r\n%s,%0i,%0i" % (meter,col_3,col_4))
reporter.send_data(message_2)
The ‘reporter’ function is the bit that sends via a Unix socket.
This is what the database looks like afterwards…
time col_1 col_2 host meter
---- ----- ----- ---- -----
1651177687434054435 1 2 pi1 something
1651177687434422446 3 4 pi1 something
However I was expecting it to look more like this, with the second message populating col_3 and col_4 based on the names I used…
time col_1 col_2 col_3 col_4 host meter
---- ----- ----- ----- ----- ---- -----
1651177687434054435 1 2 pi1 something
1651177687434422446 3 4 pi1 something
Here’s the relevant bit of telegraf.conf…
[[inputs.socket_listener]]
service_address = "unix:///tmp/telegraf.sock"
data_format = "csv"
csv_header_row_count = 1
name_override = "battpack"
data_type = "float"
csv_tag_columns = ["meter"]
Just starting out with this so hope it’s not too dumb a question, but it’s stumped me all afternoon. Any ideas what I’m doing wrong?
Dave