Hi,
We are using elastic and kibana to store and visualize automated testing data and we want to create an alerting system that sends a message to Flowdock if a certain threshold of failed tests is reached.
For this purpose I've created a monitor in kibana.
So far I've been able to set up the monitor query and destination correctly.
The response of the query is as following:
{
"_shards": {
"total": 150,
"failed": 0,
"successful": 150,
"skipped": 145
},
"hits": {
"hits": [],
"total": 79,
"max_score": 0
},
"took": 23,
"timed_out": false,
"aggregations": {
"testStepName": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"doc_count": 17,
"key": "CreateReviewBufferSession"
},
{
"doc_count": 10,
"key": "Fetch thumbnails"
},
{
"doc_count": 9,
"key": "Verify manifest"
},
{
"doc_count": 7,
"key": "Fetch manifest"
}
]
}
}
}
I'm using aggregations to us a single monitor for our alerting system. (Instead of creating and managing 32 different monitors)
Now I'm trying to create a trigger condition for this query.
I want to trigger the actions if the doc_count of one of the buckets reaches a certain value.
The painless code I have so far is as following:
for(int i=0; i < ctx.results[0].aggregations.testStepName.buckets.length;i++){
if (ctx.results[0].aggregations.testStepName.buckets[i].key === "Verify manifest") {
if (ctx.results[0].aggregations.testStepName.buckets[i].doc_count > 5) {
return true;
}
}
}
However this does not seem to work.
I still get a false as trigger condition response.
I've done some debugging and it appears I'm unable to read the key value from any of the objects in the buckets array. I am however able to read the doc_count correctly.
I've also tried using doc values (doc['field']) but I'm afraid I'm still to new to elastic to get it working that way.
If someone is able to have a look and provide some advice that would be greatly appreciated.
Regards
The version of Kibana we are running is 6.8.0