How to use input.file with json query

With this JSON

{
    "obj": {
        "name": {"first": "Tom", "last": "Anderson"},
        "age":37,
        "children": ["Sara","Alex","Jack"],
        "fav.movie": "Deer Hunter",
        "friends": [
            {"first": "Dale", "last": "Murphy", "age": 44},
            {"first": "Roger", "last": "Craig", "age": 68},
            {"first": "Jane", "last": "Murphy", "age": 47}
        ]
    }
}
[[inputs.file]]
  files = ["example"]
  data_format = "json"
  tag_keys = ["first"]
  json_string_fields = ["last"]
  json_query = "obj.friends"

This is the output

file,first=Dale last="Murphy",age=44
file,first=Roger last="Craig",age=68
file,first=Jane last="Murphy",age=47

How do I get “fav.movie”: “Deer Hunter” as one of the tags for output metric?

Hi,

Since you are specifying a json_query, only the result of that will be parsed by the parser. The favorite movie item is above the result of that query.

So your options are modify that query, use the json_v2 parser given the more complex requirements, or take a look at the xpath parser for even more control over parsing the data.

My suggestion is to use xpath as it is the most powerful of the three options and probably the one that will get you what you want.

Hi

Could you please suggest what exactly to use for this particular case with xpath ?