Answer the question
In order to leave comments, you need to log in
How to build an Elasticsearch query?
Greetings gentlemen!
There is an ELK-stack of version 5.0
Multiline events are sent from different servers to one index. One of the metrics is the state, "LaneIndic".
How to correctly construct a query in which I will pull out the last value of this state for each server?
With this request, I get the last value of LaneIndic, among all servers.
GET /logstash-test-06/log/_search?
{
"_source": ["beat.hostname", "LaneIndic", "@timestamp"],
"query" : {
"match_all": {}
},
"size": 1,
"sort": [
{
"@timestamp": {
"order": "desc"
}
}
]
}
Answer the question
In order to leave comments, you need to log in
Most likely it is necessary to do aggregation.
First aggregate by "beat.hostname" with order = "@timestamp"
Then by LaneIndic, size=1 Like
this:
{
"aggs" : {
"host" : {
"terms" : {
"field" : "beat.hostname"
},
"aggs" : { "size":1,
"lane" : { "terms" : { "field" : "LaneIndic" }, "order" : { "@timestamp" : "desc" }}
}
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question