I have one request that will calculate the average responsetime of the http request in a range time period. But I need make a filter only to get the ones which response times greater than a specific value.
Here is the SQL:
Select * avg(response_time) as avg_responsetime, clientip
where avg_responsetime>5
group by clientip.
I can got the avg response time by the elasticsearch aggregation avg. But I have no idea to add the query condition "where avg_responsetime>5"
Anyone can help me?
Here is my elasticsearch query:
{
"query" : {
"filtered": {
"filter": {
"range": {
"@timestamp": {
"from": 1430986911476,
"to": 1430987211476
}
}
}
}
},
"aggs": {
"group_by_request": {
"terms": {
"field": "request" ,
"order": { "avg_responsetime": "desc"}
},
"aggs": {
"avg_responsetime": {
"avg": {
"field": "response_time"
}
}
}
}
}
}