# Kibana alert condition

**URL:** <https://discuss.elastic.co/t/kibana-alert-condition/262645>\
**Category:** Kibana\
**Created:** [January 29, 2021, 12:27pm UTC](https://discuss.elastic.co/t/kibana-alert-condition/262645 "2021-01-29T12:27:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guy\_Assaf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guy_assaf/32/83112_2.png) [@Guy\_Assaf](https://discuss.elastic.co/u/Guy_Assaf)\
**Post date:** [January 29, 2021, 12:27pm UTC](https://discuss.elastic.co/t/kibana-alert-condition/262645/1 "2021-01-29T12:27:59Z")

</div>

See the image, I'm trying to define an alert such that a certain percentage will trigger the alert.  
Two issues:

1. how to take the ERROR/SUCCESS doc from the list, I tried with (buckets{key:SUCCESS} which does not work)
2. the divide operation round the numbers like integer, I need a float number. (0.01)

 ![Screen Shot 2021-01-29 at 14.22.33](https://us1.discourse-cdn.com/elastic/original/3X/b/a/ba6c26d9d6e1d77870210426c6e10ec78fe21d2e.png)

# Result example

{  
"\_shards": {  
"total": 2080,  
"failed": 0,  
"successful": 2080,  
"skipped": 2030  
},  
"hits": {  
"hits": ,  
"total": {  
"value": 3750,  
"relation": "eq"  
},  
"max\_score": null  
},  
"took": 51,  
"timed\_out": false,  
"aggregations": {  
"2": {  
"doc\_count": 3750,  
"buckets": [  
{  
"score": 0.0717097145653337,  
"doc\_count": 3723,  
"bg\_count": 202611071,  
"key": "SUCCESS"  
},  
{  
"score": 0.008978920146330968,  
"doc\_count": 4,  
"bg\_count": 24784,  
"key": "PARTIAL\_SUCCESS"  
},  
{  
"score": 0.0020247561180953572,  
"doc\_count": 22,  
"bg\_count": 954370,  
"key": "ERROR"  
}  
],  
"bg\_count": 218821134  
}  
}  
}

# Alert condition

ctx.results[0].aggregations.2.buckets{key:SUCCESS}.doc\_count / ctx.results[0].hits.total.value == 0

---

<div class="post-metadata">

**Author:** ![ylasri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ylasri/32/86120_2.png) [@ylasri](https://discuss.elastic.co/u/ylasri)\
**Post date:** [January 29, 2021, 1:13pm UTC](https://discuss.elastic.co/t/kibana-alert-condition/262645/2 "2021-01-29T13:13:10Z")

</div>

Hi @Guy_Assaf,  
Welcome to our community 😃  
I'm afraid that this thread is related to "AWS Open Distro", and then question may be asked [here](https://discuss.opendistrocommunity.dev/) for more relevant answers

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 26, 2021, 1:14pm UTC](https://discuss.elastic.co/t/kibana-alert-condition/262645/3 "2021-02-26T13:14:03Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
