Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fhriley opened this issue Jan 2, 2025 · 0 comments
Labels
bug unexpected problem or unintended behavior

Comments

@fhriley
Copy link
Contributor

fhriley commented Jan 2, 2025

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
        }
    }
}
@fhriley fhriley added the bug unexpected problem or unintended behavior label Jan 2, 2025
@fhriley fhriley changed the title JSON field rename doesn't work if field is the same name as another rename JSON field rename doesn't work if field path is the same path as another field Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

1 participant