Search code examples
elasticsearchkibana

How to pass custom data to response in kibana devtools


I want to execute multiple elastic search requests on AWS kibana. Because of amazon cognito auth I cannot do it using api, I have to use kibana devtools.

I've generated my requests, and I need to connect request to response. How can I attach custom string to request, so it's printed back to response? I've tried attaching things to query or fragment, and they are displayed back, but apparently they alter search results.

Example devtools request:

GET /_search?rest_total_hits_as_int=true
{
    "query": {
       ... stuff...
    }
}

and response:

{
  "took" : 18490,
  "timed_out" : false,
  "_shards" : {
    "total" : 87,
    "successful" : 87,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 126266,
    "max_score" : null,
    "hits" : [ ]
  }
}

I would like to add custom string, i.e. "ccsfewafd332rs" to both request and get it back in response so I can correlate them when running multiple requests in UI.


Solution

  • You can use named queries exactly for this purpose.

    Simply add "_name": "ccsfewafd332rs" to your top-level query and you'll get it back in the response, e.g.

    {
      "query": {
        "match_all": {
          "_name": "ccsfewafd332rs"
        }
      }
    }