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 parser reports additional metric when field and object subtable used together #9594

Closed
sjwang90 opened this issue Aug 5, 2021 · 1 comment · Fixed by #9872
Closed
Assignees
Labels
area/json json and json_v2 parser/serialiser related bug unexpected problem or unintended behavior

Comments

@sjwang90
Copy link
Contributor

sjwang90 commented Aug 5, 2021

When you use a .field + .object with your JSON parser, it an includes an extra line of the whatever .field or .tag subtables are also configured with the object.

Relevant telegraf.conf:

[[inputs.http]]
  urls = [
    "https://api.openweathermap.org/data/2.5/weather?q=london&appid=dd0be88fd6d6fa1097a785db9de880b3&units=metric"
  ]
  tagexclude = ["url", "host"]
  data_format = "json_v2"
  [[inputs.http.json_v2]]
      measurement_name = "openweather"
      [[inputs.http.json_v2.field]]
          path = "weather.#.main"
          rename = "summary"
      [[inputs.http.json_v2.field]]
          path = "weather.#.description"
      [[inputs.http.json_v2.object]]
            path = "@this"
            included_keys = ["coord_lat", "coord_lon", "main_temp", "wind_speed"] # List of JSON keys (for a nested key, prepend the parent keys with underscores) that should be only included in result
            tags = ["id", "name"] # List of JSON keys (for a nested key, prepend the parent keys with underscores) to be a tag instead of a field

[[outputs.file]]
    files = ["stdout"]

System info:

Telegraf 1.19.2

Expected behavior:

Output:

openweather,id=2.643743e+06,name=London coord_lat=51.5085,coord_lon=-0.1257,description="light rain",main_temp=16.88,summary="Rain",wind_speed=5.14 1628186541000000000

Actual behavior:

Output

openweather description="light rain",summary="Rain" 1628186541000000000
openweather,id=2.643743e+06,name=London coord_lat=51.5085,coord_lon=-0.1257,description="light rain",main_temp=16.88,summary="Rain",wind_speed=5.14 1628186541000000000
@sjwang90 sjwang90 added bug unexpected problem or unintended behavior area/json_v2 labels Aug 5, 2021
@sjwang90
Copy link
Contributor Author

sjwang90 commented Aug 5, 2021

fyi @sspaink

@sspaink sspaink self-assigned this Oct 4, 2021
@Hipska Hipska added the area/json json and json_v2 parser/serialiser related label Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/json json and json_v2 parser/serialiser related bug unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants