How to get Elasticsearch data through API?

Issue

I am trying to get metrics of our CJE instance. I would like to know whether there is a way to request CJE Elasticsearch data through API endpoints.

Environment

Resolution

How to get Elasticsearch data through API

Yes, it is possible. You can get Elasticsearch data as follows

curl -XPOST -u USER:PWD https://<ES_URL>/_search/?search_type=count -d @"query.json" > result.json

where an example query.json file looks similar to

{
    "query": {
      "filtered": {
        "query": {
          "bool": {
            "must": [{
              "range": {
                "@timestamp": {
                  "gte": 1523000000000,
                  "lte": 1523800000000
                }
              }
            }]
          }
        }
      }
    },
    "aggs": {
      "MyGrouping": {
        "terms": {
          "field": "masterName",
          "size": 0
        }
      }
    },
    "size": 5,
    "from": 100
}

It can be very useful to install Chrome ElasticSearch Head extention, which is a web front end for browsing and interacting with an Elasticsearch cluster.

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.