# Create Alert from index data

**URL:** https://discuss.elastic.co/t/create-alert-from-index-data/309745
**Category:** Kibana
**Tags:** elastic-stack-alerting
**Created:** [July 15, 2022, 2:10pm UTC](https://discuss.elastic.co/t/create-alert-from-index-data/309745 "2022-07-15T14:10:00Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![DILIP\_SHARMA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dilip_sharma/32/42672_2.png) [@DILIP\_SHARMA](https://discuss.elastic.co/u/DILIP_SHARMA)
#### Post date: [July 15, 2022, 2:10pm UTC](https://discuss.elastic.co/t/create-alert-from-index-data/309745/1 "2022-07-15T14:10:00Z")

</div>

Hi  
i am using ES Cloud 7.15.1  
i am getting log data from my website .  
now i want to write alert for that data ,  
for example if status code =500 and error = xyz , send the email .

i trying using alert from security section but when i creating the rule for my index its not returning any result , its always say 0 hit .  
but we have data for that filter in discover section.

any suggestion on this ?

regards  
Dilip

---

<div class="post-metadata">

### Author: ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)
#### Post date: [July 15, 2022, 9:06pm UTC](https://discuss.elastic.co/t/create-alert-from-index-data/309745/2 "2022-07-15T21:06:47Z")

</div>

Hi Dilip,

When I try creating a rule in Security I'm getting the same results as you. I expect a hit on my query but get 0 hits.

We might need more info on your exact rule, but I think there are different options for rules under Security than there are under Stack Management \> Rules. You might need to use the rules in this section;

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/4/d4ad7030a0b59547a478bfae3fe846bb0d1e05ee.png)

Here you can pick `Elasticsearch query` type;

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/8/7846c52c27b9985ff3ee1ee1ea9c1fe8e03a83b0.png)

In this case, I Test query and get my expected 1 document matched.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/a/8add876fa41a5d66cd8e3f98dd260eb0ea61091a.png)

I'll try to figure out why the same test in the security rules doesn't work, but hopefully this can get you going.

Tip: I did my query in Discover and then used the Inspect menu to look at the request. You really don't need or want the entire request but it's a starting point if you don't know exactly how to write the query.

Regards,  
Lee

---

<div class="post-metadata">

### Author: ![DILIP\_SHARMA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dilip_sharma/32/42672_2.png) [@DILIP\_SHARMA](https://discuss.elastic.co/u/DILIP_SHARMA)
#### Post date: [July 18, 2022, 9:52am UTC](https://discuss.elastic.co/t/create-alert-from-index-data/309745/3 "2022-07-18T09:52:44Z")

</div>

hi @LeeDr  
thanks for your input ,  
i able to create rule and connectors , but now problem is my rule only trigger 1 time when i disable and enable the rule , after that its not triggering . please help me on this .  
this is my setting -

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/6/c691f53dd5f6b7916f5e87d5225d0f1b45699209.png)

my connector setting -

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/1/91986941a71ba80e1819986a135bc8c5a02e5680.png)

Please suggest me what setting is wrong .

regards  
Dilip

---

<div class="post-metadata">

### Author: ![ying.mao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ying.mao/32/88151_2.png) [@ying.mao](https://discuss.elastic.co/u/ying.mao)
#### Post date: [July 18, 2022, 4:26pm UTC](https://discuss.elastic.co/t/create-alert-from-index-data/309745/4 "2022-07-18T16:26:46Z")

</div>

@DILIP_SHARMA

It sounds like you're running into the built-in de-duplication of matches that occurs in the Elasticsearch query rule type. Documentation here: [Elasticsearch query | Kibana Guide [master] | Elastic](https://www.elastic.co/guide/en/kibana/master/rule-type-es-query.html#_handling_multiple_matches_of_the_same_document)

To avoid this, you should set your window size the same as your "Check every" interval. Currently you are checking every minute for the last 5 days, which means you will run across the same matches in every rule run, but they will be de-duplicated. Can you set your rule to check every minute over the last minute?

---

<div class="post-metadata">

### Author: ![DILIP\_SHARMA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dilip_sharma/32/42672_2.png) [@DILIP\_SHARMA](https://discuss.elastic.co/u/DILIP_SHARMA)
#### Post date: [July 19, 2022, 7:19am UTC](https://discuss.elastic.co/t/create-alert-from-index-data/309745/5 "2022-07-19T07:19:50Z")

</div>

thanks for clarification , its working as expected .

---

<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: [August 16, 2022, 7:20am UTC](https://discuss.elastic.co/t/create-alert-from-index-data/309745/6 "2022-08-16T07:20:04Z")

</div>

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