Hello again. I'll try to give you more details about these rules' options.
The
timeframe is how much time since the current moment I consider for valid events. A value of 300 means that all the events older than 5 minutes won't be added to the internal counter.
The
frequency is the number of times the other rule must fire within the configured timeframe before the current rule is alerted.
So you can:
- Reach the configured frequency within the timeframe. Rule fired.
- Reach the configured frequency but "too slow", this is, with events too distant in time and not within the timeframe. Rule not fired.
Now, consider that the events always can match one rule at a time. But if you don't silence the <if_matched_sid> rule, you'll end up having 39 alerts of this one and 1 alert of the rule with the frequency and timeframe.
Your rules depend on 101100 but this is too general, so absolutely all resources' reports match this. You must create another intermediate rule but not alert it, see the no_log option
<group name="container,">
<!-- Rule for container resources information. -->
<rule id="101100" level="5">
<decoded_as>docker-container-resource</decoded_as>
<description>Docker: Container $(container_name) Resources</description>
<group>container_resource,</group>
</rule>
<!-- Intermediate rule to count events when container CPU usage is above 80%. No log.-->
<rule id="101101" level="5">
<if_sid>101100</if_sid>
<field name="container_cpu_usage" type="pcre2">^(0*[8-9]\d|0*[1-9]\d{2,})</field>
<description>Docker: Container $(container_name) CPU usage ($(container_cpu_usage)) is over 80%</description>
<group>container_resource,</group>
<options>no_log</options>
</rule>
<!-- Rule to trigger when container CPU usage is above 80% within the last 5 minutes -->
<rule id="101102" level="12" frequency="40" timeframe="300">
<if_matched_sid>101101</if_matched_sid>
<description>Docker: Container $(container_name) CPU usage ($(container_cpu_usage)) is over 80% for the last 5 min</description>
<group>container_resource,</group>
</rule>
</group>
Please, try this approach and come back with the results.
Regards.