JSON v2 parsing - variable string inside path

CZvacko
Thu, 10 Jul 2025 13:28:28 +0000
Telegraf

Hello, I am trying to parse the json below (which comes from IOT / BSB-LAN).
It is truncated to 3 objects (8005, 8009, 8308), but I actually have more objects, based on the device settings (the user can define which device parameters he wants to query by http).

And I don’t know how to properly define the path for json_v2.object. It should be a variable, because http query can change from time to time.
I ended up with the configuration below, but there I had to explicitly define a path (which is actually Tag) for each object.

  [[inputs.http.json_v2]]
    [[inputs.http.json_v2.object]]
      path = "8005"
      tags = ["name"]
      included_keys = ["value", "desc"]
    [[inputs.http.json_v2.object]]
      path = "8009"
      tags = ["name"]
      included_keys = ["value", "desc"]
    [[inputs.http.json_v2.object]]
      path = "8308"
      tags = ["name"]
      included_keys = ["value", "desc"]

json (click for more details)
5 posts - 2 participants