aboutsummaryrefslogtreecommitdiffstats
path: root/test/policies/monitor/policy.rego
diff options
context:
space:
mode:
Diffstat (limited to 'test/policies/monitor/policy.rego')
-rw-r--r--test/policies/monitor/policy.rego39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/policies/monitor/policy.rego b/test/policies/monitor/policy.rego
new file mode 100644
index 0000000..b3d9aaa
--- /dev/null
+++ b/test/policies/monitor/policy.rego
@@ -0,0 +1,39 @@
+package monitor
+
+# Policy allows if a matching threshold is met
+result contains output if {
+ input.domain = data.node.monitor.domain
+ some events in data.node.monitor.metricsPerEventName
+ events.eventName == input.eventName
+ events.controlLoopSchemaType == input.controlLoopSchemaType
+ events.policyScope == input.policyScope
+ events.policyName == input.policyName
+ events.policyVersion == input.policyVersion
+ some value in events.thresholds
+ input.controlname == value.closedLoopControlName
+ input.version == value.version
+ input.thresholdValue == value.thresholdValue
+ output := {
+ "severity" : "MAJOR",
+ "closedLoopEventStatus" : "ABATED"
+ }
+}
+
+# Policy allows if a matching threshold is met
+result contains output if {
+ input.domain = data.node.monitor.domain
+ some events in data.node.monitor.metricsPerEventName
+ events.eventName == input.eventName
+ events.controlLoopSchemaType == input.controlLoopSchemaType
+ events.policyScope == input.policyScope
+ events.policyName == input.policyName
+ events.policyVersion == input.policyVersion
+ some value in events.thresholds
+ input.controlname == value.closedLoopControlName
+ input.version == value.version
+ input.thresholdValue > value.thresholdValue
+ output := {
+ "severity" : "CRITICAL",
+ "closedLoopEventStatus" : "ONSET"
+ }
+}