Search code examples
elasticsearchlucenegrafana

Grafana query filter by key and value


In my Grafana ElasticSearch Datasource, I have an attribute like this:

=== object_attributes.variables ====
[ 
  { "key": "fruit", "value": "apple" }, 
  { "key": "fruit", "value": "banana" }, 
  { "key": "game", "value": "cricket" }, 
  { "key": "game", "value": "football" }
]

=== object_attributes.status =====
["failed","all","xxx"] or ["passed","all","xxx"]

So, When I Query like this

  1. * AND object_attributes.status:"passed" I get Expected Results
  2. * AND object_attributes.status:"passed" AND object_attributes.variable:{ "key": "fruit", "value": "banana" } I get no results.

Basically, I want to filter all attributes by fruit: banana and passed. So, How Do I modify point 2 to get results?


Solution

  • I figured it out by myself.

    I was running the Query below and I was able to get the results as expected.

    * AND object_attributes.status:"passed" AND object_attributes.variable.key:"fruit" AND object_attributes.variable.value:"banana"
    

    So, Instead of Running object_attributes.variable:{ "key": "fruit", "value": "banana" } I was running both object_attributes.variable.key:"fruit" AND object_attributes.variable.value:"banana" and its working like a charm.