java.lang.Object
org.sentrysoftware.metricshub.engine.alert.AlertRule

public class AlertRule extends Object
Represents an alert rule used for monitoring conditions and triggering alerts based on those conditions.
  • 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

      public void evaluate(Monitor monitor)
      Evaluate the current AlertRule
      Parameters:
      monitor - The monitor on wish we apply the condition
    • getActive

      public AlertRuleState 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:
      true or false
    • copy

      public AlertRule copy()
      Copy the current alert rule and build a new one
      Returns:
      a new alert rule
    • same

      public boolean same(Object obj)
      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