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
- CloudBees Jenkins Platform - Operations Center (CJP-OC)
- CloudBees Jenkins Analytics
- Remote Elasticsearch
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": "controllerName",
"size": 0
}
}
},
"size": 5,
"from": 100
}
It can be very useful to install Chrome ElasticSearch Head extension, which is a web front end for browsing and interacting with an Elasticsearch cluster.
0 Comments