######### into json msg ######################
{
“y”: 1111111.354243171,
“x”: 1111111.9858582001,
“speed”: [0.0, 1.0, 2.0, 4.0],
“angle”: [
0.35431448844127544, 0.09063859006636221,
0.35431448844127544, 0.09063859006636221,
-0.08514534218357994, 0.35431448844127544,
-0.2609292744335221, 0.1785305561913333
],
“name”: “A001”,
“left_behind_at”: 1634607917.8445928,
“odometer”: [9.9, 9.1, 9.5, 6.6000000000000005, 9.9, 10.100000000000001, 9.5, 7.9],
“distance”: 0.0,
“gy”: 957004.5313795683,
“current_throttle”: 0.0,
“points”: [{“type”: 0, “x”: -27.771453857421875, “y”: 7.960874557495117},
{“type”: 0, “x”: -26.048484802246094, “y”: 7.958527565002441},
{“type”: 16, “x”: 14.540033340454102, “y”: -25.705089569091797}
],
“time”: str(datetime.datetime.utcnow().strftime("%Y-%m-%dT %H:%M%SZ"))
}
############### telegraf config #########################
[[inputs.mqtt_consumer]]
data_format = “json_v2”
[[inputs.mqtt_consumer.json_v2]]
measurement_name = “vehicle_status”
[[inputs.file.json_v2.tag]]
path = “name”
rename = “vehicle”
[[inputs.mqtt_consumer.json_v2.object]]
path = “@this”
disable_prepend_keys = false
excluded_keys = [“points”]
[[inputs.mqtt_consumer.json_v2.object.field]]
path = “speed.0”
rename = “speed_1”
type = “float”
############# objective ############
filter “points” field
“odometer” into influxdb array type
“speed” field parser as follows :
field speed_1, speed_2,speed_3,speed_4
But Store results “speed”, “odometer” array type field
There is only the last value
pivot after