Getting number of hits for each unique query_key #1176
-
hello everyone, I have following rule :
I want to alert when each unique supplierName has more than 35 logs with "Error" level in last 10 minute from current time at the moment I used num_hits to get error count for each unique supplierName, when an alert sends to Microsoft teams channel I open the kibana dashboard and write a query for past 10 minute for that specific supplierName which is specified in the alert message with level : Error, then the number of hits returned from query is different from Error count that specified in Microsoft teams alert message My question is how to send the count of errors(currently I am using num_hits) of each unique supplier in the last 10 minutes in the alert message? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Unfortunately, the counts per query_key are not currently made available to the alerters. timeframe: Setting to 10 minutes instructs the rules to only include records that fall within the past 10 minutes. Therefore, your rule will query Elasticsearch every 10 seconds and each query will overlap the previous query time window by 9m 50s. For each result in the query, ElastAlert 2 will compare the @timestamp on the result with the timerange. If it's within 10m then it will add it to the match set, which is remembered across queries. So it would appear your buffer_time of 10m is sufficient. If you wanted to make sure you don't miss any data you could extend it to a larger window, perhaps 15m. But then this would cause your query to have a larger time window, and you stated above you only want the query to execute for the last 10 minutes, however, you didn't explain why you want this. Your timeframe of 10m is also correct since you stated you only want to alert on events occurring in the past 10 minutes. |
Beta Was this translation helpful? Give feedback.
Unfortunately, the counts per query_key are not currently made available to the alerters.
timeframe: Setting to 10 minutes instructs the rules to only include records that fall within the past 10 minutes.
buffer_time: Setting to 10 minutes instructs ElastAlert 2 to query from 10m ago till present.
run_every: Setting to 10 seconds instructs ElastAlert 2 to run the rule every 10 seconds.
Therefore, your rule will query Elasticsearch every 10 seconds and each query will overlap the previous query time window by 9m 50s. For each result in the query, ElastAlert 2 will compare the @timestamp on the result with the timerange. If it's within 10m then it will add it to the match set, which is reme…