Hi,
I´m trying to ingest some JSON data from an IoT scenario, but can’t get my head around how to ingest some JSON arrays.
I got the following data:
{ "device_name": "_5_115_3_TK_Emmastr_14", "properties": [ { "last_changed": "2021-04-13T12:22:20.823+02:00", "name": "N01 IL1", "type": "MeasureValue", "value": 0.3552161455154419 }, { "last_changed": "2021-04-13T12:22:20.823+02:00", "name": "N01 IL2", "type": "MeasureValue", "value": 0.9352161455154419 } ] }
What I need is device_name, last_changed(as the timestamp), name, value.
So the output would be:
_5_115_3_TK_Emmastr_14,unixtimestamp, N01 IL1, 0.3552161455154419 _5_115_3_TK_Emmastr_14,unixtimestamp, N01 IL2, 0.9352161455154419
My input/output config look like this:
[[inputs.file]]
files = ["/home/goodvirus/Downloads/example.json"]
data_format = "json"
json_time_key = "properties_last_changed"
json_time_format = "2006-01-02T15:04:05.000+02:00"
[[outputs.file]]
files = ["stdout", "/home/goodvirus/Downloads/metrics.out"]
data_format = "json"
json_timestamp_units = "1s"
I have looked in many posts and it seems that there is no solution, which would be really sad because then I would have to write an additional program to flatten the JSON and then I would reconsider using influx as an database, because I will probably have some similar tasks in the future for data ingestion.
Any pointers?
Thanks in advance!
Paul