Skip to content

plugins/parsers/json: tag_keys can not be applied to sub-objects #6853

@igomura

Description

@igomura

Relevant telegraf.conf:

[[inputs.file]]
files = ["data.json"]
data_format = "json"
tag_keys = [
  "Serial",
  "Model",
  "Firmware",
]

System info:

Linux CentOS 7.7
Telegraf v1.12.6

Steps to reproduce:

Input Data:

{
  "device0": {
    "Count": 0,
    "Errors": 0,
    "Serial": "9JHNGTUT",
    "Model": "WDC WUH721414ALE604",
    "Firmware": "LDGSW07G"
  },
  "device1": {
    "Count": 0,
    "Errors": 0,
    "Serial": "9JHLPW9T",
    "Model": "WDC WUH721414ALE604",
    "Firmware": "LDGSW07G"
  }
}

Expected behavior:

file,Firmware=LDGSW07G,Model=WDC\ WUH721414ALE604,Serial=9JHNGTUT device0_Count=0,device0_Errors=0 1578088300000000000
file,Firmware=LDGSW07G,Model=WDC\ WUH721414ALE604,Serial=9JHLPW9T device1_Errors=0,device1_Count=0 1578088300000000000

Actual behavior:

file device0_Count=0,device1_Count=0,device0_Errors=0,device1_Errors=0 1578088240000000000

Additional info:

In opposite, data below will pickup tags but there is no place for path which can be important key

[
  {
    "Count": 0,
    "Errors": 0,
    "Serial": "9JHNGTUT",
    "Model": "WDC WUH721414ALE604",
    "Firmware": "LDGSW07G"
  },
  {
    "Count": 0,
    "Errors": 0,
    "Serial": "9JHLPW9T",
    "Model": "WDC WUH721414ALE604",
    "Firmware": "LDGSW07G"
  }
]

file,Firmware=LDGSW07G,Model=WDC\ WUH721414ALE604,Serial=9JHLPW9T Errors=0,Count=0 1578088310000000000
file,Firmware=LDGSW07G,Model=WDC\ WUH721414ALE604,Serial=9JHNGTUT Count=0,Errors=0 1578088310000000000

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/jsonjson and json_v2 parser/serialiser relatedfeature requestRequests for new plugin and for new features to existing plugins

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions