Comparing values percentually #1600
-
Hi. I'm trying to create a rule that triggers when a duration is 150% above the average time of the last 10 minutes, grouped by an Id. I created an elasticsearch transform to facilitate this process, in which it returns that average time grouped by said Id. Here's a simple example in case I didn't explain it well: Long story short, I need to know when X number is 150% or more the value of Y. Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 6 replies
-
Perhaps the Spike Aggregation rule type will solve your needs. Documentation is online at https://elastalert2.readthedocs.io/en/latest/ruletypes.html#spike-aggregation. |
Beta Was this translation helpful? Give feedback.
-
Do some timerange windows not have any events? |
Beta Was this translation helpful? Give feedback.
-
Ok, try specifying |
Beta Was this translation helpful? Give feedback.
-
Ignore that last message I deleted, it turned out to be history messages that, since the response was 404, didn't mark them as sent, so it kept sending them. I just got confused because of the timespans. However, I'm not getting any results anymore, even tho I changed spike_height to 1 and spike_type to both. The only change are the timeframe minutes that I updated to 5, besides that, the rule mantains the same structure. Here is some debug information: elastalert2-1 | 2025-01-23 11:48:47,990 DEBUG Looking for jobs to run I apologize for being a bore. |
Beta Was this translation helpful? Give feedback.
-
I am also not sure if this is working properly everytime. When I have multiple calls with different query_keys, I suspect that, if one of them does not have something to compare to, it breaks all the cycle, not sending any alerts about anything, even if another query_key was compatible with the rule. My suspicion derives from the log, that does not give me a similiar line to this: Here are the logs when the error occurs |
Beta Was this translation helpful? Give feedback.
-
I've already fixed that error and so the next release will avoid crashing the rule in that situation. You can try it now by using the nightly build. To do so, switch to the |
Beta Was this translation helpful? Give feedback.
-
I don't want to be a nuisance, but it still throws an error, but on the next line: elastalert2-1 | File "/usr/local/lib/python3.13/site-packages/elastalert/ruletypes.py", line 528, in find_matches I suppose "ref is not None" on the if would solve the problem. |
Beta Was this translation helpful? Give feedback.
-
I'm sorry for coming back to this ticket, but I have a question. Does Spike Aggregation compare the average of the current values in the timeframe to the average of the values in the buffer_time? Or all the values of said timeframe individually? If the former, how would I compare it individually? |
Beta Was this translation helpful? Give feedback.
-
It compares the mean of the current timeframe to the mean of the reference timeframe. |
Beta Was this translation helpful? Give feedback.
-
How would I compare the individual values? Imagine, I would like to know if said trace took more time than it should, comparing it to the average. If I compare the mean to the mean, if, in the timeframe, I have a value that is too low, it might ignore the high value. |
Beta Was this translation helpful? Give feedback.
-
Perhaps use |
Beta Was this translation helpful? Give feedback.
Ok, try specifying
disable_rules_on_error: false
and let's see if the rule behaves as expected, aside from the error when there's no data.