> And always alert is getting triggered even if I keep input series value as 0.
No, the alert is *not* being triggered. That's what "got: []" means: "I got an empty list of alerts" (although your test is written to *expect* a non-empty list of alerts, so the reality doesn't match expectations)
> Any help on this please?
Well, to start with:
100000000/1024/1024/1024 *100 = 9.31322574
So you need to add a zero to your test values.
Secondly, your alerting rule has "for: 5m". If you keep this, then the alert condition has to have been true for 5 minutes, and has to be evaluated at 5 minutes. So you need:
values: '1000000000 1000000000 1000000000 1000000000 1000000000 1000000000'
and uncomment "eval_time: 5m"
Alternatively, you can comment out "for: 5m" in your alerting rule, in which case you only need
After this, your alert triggers (it "got" an alert), but you'll find the labels and annotations don't match exactly what you'd put in the expectations:
FAILED:
alertname: ServiceMemoryUsage90Percent, time: 5m,
exp:[
0:
Labels:{alert_owner="alerts-infra", alertname="ServiceMemoryUsage90Percent", severity="Critical"}
Annotations:{description="Service memory has been at over 90% for 1 minute. Service: (), DnsName: ()."}
],
got:[
0:
Labels:{alert_owner="alerts-infra", alertname="ServiceMemoryUsage90Percent", container_label_io_rancher_stack_name="network-service", severity="Critical"}
Annotations:{description="Service memory has been at over 90% for 1 minute. Service: network-service, DnsName: . \n"}
]
You can then modify your expectations to make them match what the alerting rule actually generates - or you can modify the alerting rule itself to generate a different set of labels and annotations.