How to insert a string array to influxDB with JSON format?

telegraf
#1

Hi guys,
I am trying to using telegraf to collect sensor data and insert to influxDB.
I am coming up with a trouble.
That is, how to insert a string array to influxDB with JSON format?

Here is my telegraf.conf

[[inputs.mqtt_consumer]]
/**************************
…,…
data_format = “json”
tag_keys = [
“voltage”,
“time_ori”,
]


*********************/

And, following are my MQTT publisher’s content,
{“voltage”:[22, 44], “time_ori”:[“aaa”,“bbb”] }

I can see voltage is insert to DB successfully, but “time_ori” fail.
May I misunderstand something?
Thanks a lot.

#2

Hi @Cloud-lee,

The correct format for using arrays is explained in our documentation. The array of points should be the root element, and not arrays within tag values:

[{“voltage”:22, “time_ori”:“aaa”}`

should become

[
    {“voltage”: 22, “time_ori”: "aaa”}
    {"voltage": 44, "time_ori": "bbb"}
]