MQTT Json Structure to InfluxDB

time-series

#1

My MQTT Tag
{UUID}/Values

looks like:

{
          "TagData": [
                    {
                              "Time": "2019-01-07T22:41:04.781+01:00",
                              "Values": {
                                        "TagA": 50.102245,
                                        "TagB": 49.589504,
                                        "TagC": 0.620247,
                              }
                    },
                    {
                              "Time": "2019-01-07T22:41:14.782+01:00",
                              "Values": {
                                        "TagA": 50.06562,
                                        "TagB": 49.552876,
                                        "TagC": 0.620247,
                              }
                    },
                    {
                              "Time": "2019-01-07T22:41:24.832+01:00",
                              "Values": {
                                        "TagA": 50.06562,
                                        "TagB": 49.589504,
                                        "TagC": 0.620247,
                              }
                    }
          ]
}

My /etc/telegraf/telegraf.conf contains:

[[inputs.mqtt_consumer]]
  
[...................]

  ## Topics to subscribe to
  topics = [
        "+/TagValues",
  ]
  data_format = "json"

 tag_keys = ["TagData.Values"]
  json_time_format = "2006-01-02T15:04:05Z07:00"
  json_time_key = "Time"
  json_query = "TagData"

My InfluxDB output looks like:

[
  {
    "time": "2019-01-07T21:31:34.591Z",
    "TagA": 49.858082,
    "TagB": 49.467422,
    "TagC": 0.621639,
    "topic": "{UUID}/TagValues"
  },
  {
    "time": "2019-01-07T21:31:44.591Z",
    "TagA": 49.980164,
    "TagB": 49.516251,
    "TagC": 0.620247,
    "topic": "{UUID}/TagValues"
  },
  ...
]

How could i seperate this to a structure like:

[
  {
    "time": "2019-01-07T21:31:34.591Z",
    "Tag": "TagA",
    "Value": 49.858082,
    "topic": "{UUID}/TagValues"
  }, 
  {
    "time": "2019-01-07T21:31:34.591Z",
    "Tag": "TagB",
    "Value": 49.467422,
    "topic": "{UUID}/TagValues"
  }, 
  ...
]

Thanks for your help appreciated.
Andreas