Skip to content

JSON field rename doesn't work if field path is the same path as another field #16361

Description

@fhriley

Relevant telegraf.conf

data_format = "json_v2"

[[inputs.http.json_v2]]
  measurement_name = "energy"

  [[inputs.http.json_v2.object]]
    path = "production.eim"
    disable_prepend_keys = true

    [[inputs.http.json_v2.object.field]]
      path = "wattHoursLifetime"
      rename = "production"

  [[inputs.http.json_v2.object]]
    path = "consumption.eim"
    disable_prepend_keys = true

    [[inputs.http.json_v2.object.field]]
      path = "wattHoursLifetime"
      rename = "consumption"

Logs from Telegraf

telegraf-telegraf-energy-1  | 2025-01-02T02:31:19Z I! Starting Telegraf 1.33.0 brought to you by InfluxData the makers of InfluxDB
telegraf-telegraf-energy-1  | 2025-01-02T02:31:19Z I! Available plugins: 236 inputs, 9 aggregators, 33 processors, 26 parsers, 63 outputs, 6 secret-stores
telegraf-telegraf-energy-1  | 2025-01-02T02:31:19Z I! Loaded inputs: http
telegraf-telegraf-energy-1  | 2025-01-02T02:31:19Z I! Loaded aggregators:
telegraf-telegraf-energy-1  | 2025-01-02T02:31:19Z I! Loaded processors:
telegraf-telegraf-energy-1  | 2025-01-02T02:31:19Z I! Loaded secretstores:
telegraf-telegraf-energy-1  | 2025-01-02T02:31:19Z W! Outputs are not used in testing mode!
telegraf-telegraf-energy-1  | 2025-01-02T02:31:19Z I! Tags enabled:
telegraf-telegraf-energy-1  | 2025-01-02T02:31:19Z D! [agent] Initializing plugins
telegraf-telegraf-energy-1  | 2025-01-02T02:31:19Z D! [agent] Starting service inputs
telegraf-telegraf-energy-1  | 2025-01-02T02:31:19Z D! [agent] Stopping service inputs
telegraf-telegraf-energy-1  | > energy production=529980 1735785080000000000
telegraf-telegraf-energy-1  | > energy production=326544 1735785080000000000
telegraf-telegraf-energy-1  | 2025-01-02T02:31:19Z D! [agent] Input channel closed
telegraf-telegraf-energy-1  | 2025-01-02T02:31:19Z D! [agent] Stopped Successfully

System info

1.33.0

Docker

No response

Steps to reproduce

  1. Parse the included input with the include telegraf config

...

Expected behavior

Second telegraf output above is "consumption" rather than "production"

Actual behavior

Both are "production"

Additional info

Input:

{
    "production": {
        "pcu": {
            "wattHoursToday": 34068,
            "wattHoursSevenDays": 215538,
            "wattHoursLifetime": 530426,
            "wattsNow": 0
        },
        "rgm": {
            "wattHoursToday": 0,
            "wattHoursSevenDays": 0,
            "wattHoursLifetime": 0,
            "wattsNow": 0
        },
        "eim": {
            "wattHoursToday": 33846,
            "wattHoursSevenDays": 214168,
            "wattHoursLifetime": 529980,
            "wattsNow": 0
        }
    },
    "consumption": {
        "eim": {
            "wattHoursToday": 21802,
            "wattHoursSevenDays": 128554,
            "wattHoursLifetime": 326193,
            "wattsNow": 627
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugunexpected problem or unintended behavior

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions