I want to create a advanced watch wich count a specific operation of specific service during more than 1 second to execute. If the number of cases is greater than 1% of total of cases, the watch send a alert. Ex: (duration / total > 0,01 )
My goal is to be able to divide the number of cases that during more than 1s by total of cases to obtain the percentage.
I did a query with the two aggs that i need for the division, but i can't reach the calculate part.
Is it even possible? If so, how?
My query:
GET test-*/_search?size=0
{
"query": {
"term": {
"Service.keyword": "se"
}
},
"aggs": {
"total": {
"filter": {
"term": {
"Operation.keyword": "op"
}
},
"aggs": {
"duration": {
"filter": {
"range": {
"Duration": {
"gte": 1000
}
}
}
}
}
}
}
}
Result:
{
"took" : 328,
"timed_out" : false,
"_shards" : {
"total" : 52,
"successful" : 52,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 334,
"max_score" : 0.0,
"hits" :
},
"aggregations" : {
"total" : {
"doc_count" : 296,
"duration" : {
"doc_count" : 19
}
}
}
}