Exemple #1
0
def validate_observations(alert_id: int, label: str, session: Session) -> bool:
    """
    Runs an alert's validators to check if it should be triggered or not
    If so, return the name of the validator that returned true
    """

    logger.info("Validating observations for alert <%s:%s>", alert_id, label)
    alert = session.query(Alert).get(alert_id)
    validate = get_validator_function(alert.validator_type)
    return bool(validate and validate(alert, alert.validator_config))
Exemple #2
0
def validate_observations(alert_id: int, label: str) -> bool:
    """
    Runs an alert's validators to check if it should be triggered or not
    If so, return the name of the validator that returned true
    """

    logger.info("Validating observations for alert <%s:%s>", alert_id, label)

    alert = db.session.query(Alert).get(alert_id)
    if alert.validators:
        validator = alert.validators[0]
        validate = get_validator_function(validator.validator_type)
        if validate and validate(alert.sql_observer[0], validator.config):
            return True

    return False