Class AlertRule
java.lang.Object
org.sentrysoftware.metricshub.engine.alert.AlertRule
Represents an alert rule used for monitoring conditions and triggering alerts based on those conditions.
-
Constructor Summary
ConstructorsConstructorDescriptionAlertRule(@NonNull BiFunction<Monitor, Set<AlertCondition>, AlertDetails> conditionsChecker, @NonNull Set<AlertCondition> conditions, long period, @NonNull Severity severity) Creates an AlertRule instance with the specified conditionsChecker, conditions, period, and severity.AlertRule(@NonNull BiFunction<Monitor, Set<AlertCondition>, AlertDetails> conditionsChecker, @NonNull Set<AlertCondition> conditions, long period, @NonNull Severity severity, @NonNull AlertRuleType type) Creates an AlertRule instance with the specified conditionsChecker, conditions, period, severity, and type.AlertRule(@NonNull BiFunction<Monitor, Set<AlertCondition>, AlertDetails> conditionsChecker, @NonNull Set<AlertCondition> conditions, @NonNull Severity severity) Creates an AlertRule instance with the specified conditionsChecker, conditions, and severity.AlertRule(@NonNull BiFunction<Monitor, Set<AlertCondition>, AlertDetails> conditionsChecker, @NonNull Set<AlertCondition> conditions, @NonNull Severity severity, @NonNull AlertRuleType type) Creates an AlertRule instance with the specified conditionsChecker, conditions, severity, and type. -
Method Summary
-
Constructor Details
-
AlertRule
public AlertRule(@NonNull @NonNull BiFunction<Monitor, Set<AlertCondition>, AlertDetails> conditionsChecker, @NonNull @NonNull Set<AlertCondition> conditions, long period, @NonNull @NonNull Severity severity, @NonNull @NonNull AlertRuleType type) Creates an AlertRule instance with the specified conditionsChecker, conditions, period, severity, and type.- Parameters:
conditionsChecker- A function that checks conditions and returns alert details.conditions- A set of alert conditions.period- The time period for the alert rule.severity- The severity level of the alert rule.type- The type of the alert rule.
-
AlertRule
public AlertRule(@NonNull @NonNull BiFunction<Monitor, Set<AlertCondition>, AlertDetails> conditionsChecker, @NonNull @NonNull Set<AlertCondition> conditions, @NonNull @NonNull Severity severity, @NonNull @NonNull AlertRuleType type) Creates an AlertRule instance with the specified conditionsChecker, conditions, severity, and type.- Parameters:
conditionsChecker- A function that checks conditions and returns alert details.conditions- A set of alert conditions.severity- The severity level of the alert rule.type- The type of the alert rule.
-
AlertRule
public AlertRule(@NonNull @NonNull BiFunction<Monitor, Set<AlertCondition>, AlertDetails> conditionsChecker, @NonNull @NonNull Set<AlertCondition> conditions, long period, @NonNull @NonNull Severity severity) Creates an AlertRule instance with the specified conditionsChecker, conditions, period, and severity.- Parameters:
conditionsChecker- A function that checks conditions and returns alert details.conditions- A set of alert conditions.period- The time period for the alert rule.severity- The severity level of the alert rule.
-
AlertRule
public AlertRule(@NonNull @NonNull BiFunction<Monitor, Set<AlertCondition>, AlertDetails> conditionsChecker, @NonNull @NonNull Set<AlertCondition> conditions, @NonNull @NonNull Severity severity) Creates an AlertRule instance with the specified conditionsChecker, conditions, and severity.- Parameters:
conditionsChecker- A function that checks conditions and returns alert details.conditions- A set of alert conditions.severity- The severity level of the alert rule.
-
-
Method Details
-
evaluate
Evaluate the currentAlertRule- Parameters:
monitor- The monitor on wish we apply the condition
-
getActive
Get the alert rule state. This method refreshes the current AlertRule before returning its state- Returns:
AlertRuleState: INACTIVE, PENDING or ACTIVE
-
isActive
public boolean isActive()Check if the current AlertRule is active- Returns:
trueorfalse
-
copy
Copy the current alert rule and build a new one- Returns:
- a new alert rule
-
same
Check if the given object is the same as the current AlertRule instance.
Must match the three fields conditions, period and severity- Parameters:
obj- The object we wish to compare- Returns:
- true or false
-