Nested json key as a tag value

I am trying to get nested json values setup as a tag. For some reason this doesn’t seem to work. I am just wondering if I am attempting this correctly.

If this is my json input:

{
“ID”:“550d74a9-d4cd-40ae-9a1b-8fde08353417”,
“source”:“2d05c85d-1081-4a36-a421-0dadb7f609cd”,
“eventDate”:1524162885648,
“eventType”:“CALL_LEG_STARTED_EVENT”,
“body”:{
“ID”:“e3060dba-7e53-4b9e-ab5f-357ea9321fb1”,
“type”:“DIRECTMEDIA”,
],
}
}

Of course the eventDate gets converted into a measurement. I have the tagKeys setup to pull ID and source and that works perfectly. The issue crops up when I try to set for example the ‘type’ key as a tag.

I have tried the following methods unsuccessfully:

tag_keys = [
“ID”,
“source”,
“body.type”,
]

tag_keys = [
“ID”,
“source”,
“body_type”,
]

Any help would be appreciated!

I don’t think it is possible, can you open a new issue to add this?

Thank you for replying.

I found this issue already which details it at the top but doesn’t look like it’s been implemented.

Is there a good way of trying to get some traction on this issue? It seems this issue is many things in one and maybe needs to be split up as just this piece would be extremely useful.

I think supporting nested keys is probably something separate from this idea for a very flexible JSON parser, the fastest way to get it supported is submitting a pull request or pinging your sales representative.

@Tristan_Lanford, once this gets merged/released,
You will be able to get the output:

exec,ID=550d74a9-d4cd-40ae-9a1b-8fde08353417,body_type=DIRECTMEDIA,host=test,source=2d05c85d-1081-4a36-a421-0dadb7f609cd eventDate=1524162885648 1532619160000000000

With the following telegraf.conf:

[[inputs.exec]]
  data_format = "json"
  tag_keys = [
    "ID",
    "source",
    "body_type",
  ]
  commands = [
    "echo '{  \"ID\": \"550d74a9-d4cd-40ae-9a1b-8fde08353417\",  \"source\": \"2d05c85d-1081-4a36-a421-0dadb7f609cd\",  \"eventDate\": 1524162885648,  \"eventType\": \"CALL_LEG_STARTED_EVENT\",  \"body\": {    \"ID\": \"e3060dba-7e53-4b9e-ab5f-357ea9321fb1\",    \"type\": \"DIRECTMEDIA\"  }}'",
  ]

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

Note the tag_keys on the input and the originally desired output.