I'm trying to create a request where I can extract a specific metric from Elasticsearch, so I could manage data faster. I got rid of metadata and unnecessary data with a request as follow :
get localhost:9200/metricbeat-7.12.0/_search?size=2000&pretty&filter_path=hits.hits._source
{
"_source": ["@timestamp", "labels","prometheus"]
}
I get something like that which is closer to what I want. Now I would like an additional filter where I get only the metrics "prometheus.metrics.windows_cpu_time_total" and not the other metrics.
{
"hits": {
"hits": [
{
{
"_source": {
"@timestamp": "2021-04-29T15:35:57.518Z",
"prometheus": {
"metrics": {
"windows_service_status": 0
},
"labels": {
"instance": "localhost:9182",
"name": "timebrokersvc",
"job": "prometheus",
"status": "lost comm"
}
}
}
},
{
"_source": {
"@timestamp": "2021-04-29T15:35:57.518Z",
"prometheus": {
"metrics": {
"windows_cpu_time_total": 29480.625
},
"labels": {
"mode": "idle",
"core": "0,0",
"instance": "localhost:9182",
"job": "prometheus"
}
}
}
}}]}}
I tried a field search which doesn't seem to work as well. Could someone point me to what's going wrong with my queries?
{
"query": {
"match_all": {}
},
"fields": [
"prometheus.metrics",
{
"field": "windows_cpu_time_total"
}]
}
Thank you in advance