Search code examples
elasticsearchaws-elasticsearch

Tagging Elastic Search Slow Query


My ElasticSearch cluster is in AWS cloud and is on version 7.8. I am trying to tag my elastic search queries so that I can identify who are the originators of the slow queries once I have them in the slow query log. I went through the elastic.co guide here which outlines the procedure to use analytics key to add tags to the query.

However, when I run my query with the analytics tag I get the error below. Also, PFA below a snapshot of the query and response.

Can someone suggest what I am doing wrong ?

Secondly, If analytics tag is something which is not available in AWS ElasticSearch then can someone suggest that what could be the alternatives to tag my queries ?

{
  "error" : {
    "root_cause" : [
      {
        "type" : "parsing_exception",
        "reason" : "Unknown key for a START_OBJECT in [analytics].",
        "line" : 156,
        "col" : 16
      }
    ],
    "type" : "parsing_exception",
    "reason" : "Unknown key for a START_OBJECT in [analytics].",
    "line" : 156,
    "col" : 16
  },
  "status" : 400
}

Query and Kibana Response


Solution

  • The documentation you're referring to is for App Search which is another product of the Elastic Stack but not Elasticsearch itself.

    What you need to do instead is to use named queries which allow you to do pretty much the same as you expect.

    What you can do is simply tag the top-level bool query

    "query": {
      "bool": {
        "_name": "your-client-tag",
        "must": [
          {
           "bool": {