I'm making an application where data from a Virtual Machine that relate to CPU usage, memory usage, disk utilization, etc. are collected via an interval HTTP request every 5 seconds. The data gathered look like this:
timeStamp (long): 1533554434
memUsagePerc (double): 5.384678498028317
cpuUsagePerc (double): 24.8756219
diskSizePerc (double): 31.880938915483163
diskUtilPerc (double): 1.0505864
I created some rules on Drools Fusion trying to see the following:
When the CPU usage reaches for example over 10% for the last 10 seconds, then print something on the screen, but my problem is that even though I put in the rule the command over window:time(Xs)
the rule is still fired even though the X seconds
have not been passed yet. Here is a rule for the CPU usage:
declare Netdata
@role( event )
end
rule "CPU usage over 10%"
salience -1
when
$cpu : Netdata(cpuUsagePerc > 10)
over window:time (10s)
from entry-point Netdata
then
System.out.println("CPU usage over 10%");
end
Netdata
is the class that collects all the data from the HTTP response and creates an object every time. That object is then used by Drools Fusion.
Note that a more "dummy" rule without the over window:time(Xs)
part is fired, too. Also, the following error turns up on the screen, next to the over window:time(Xs)
: JAVA_IDENTIFIER expected, got 'window'
I'm using Drools version 5.1.1.