Schema:

ACCOUNT_USAGE

ALERT_HISTORY view¶

This Account Usage view enables you to retrieve the history of alert usage within the last 365 days (1 year). The view displays one row for each run of a alert in the history.

Columns¶

Column Name

Data Type

Description

NAME

VARCHAR

Name of the alert.

DATABASE_NAME

VARCHAR

Name of the database that contains the alert.

SCHEMA_NAME

VARCHAR

Name of the schema that contains the alert.

CONDITION

VARCHAR

Text of the SQL statement that serves as the condition for the alert.

CONDITION_QUERY_ID

VARCHAR

Internal/system-generated identifier for the SQL statement executed as the condition of the alert.

ACTION

VARCHAR

Text of the SQL statement that serves as the action for the alert.

ACTION_QUERY_ID

VARCHAR

Internal/system-generated identifier for the SQL statement executed as the action of the alert.

ERROR_CODE

NUMBER

Error code, if the statement returned an error or failed to execute (e.g. if the current user did not have privileges to execute the alert).

ERROR_MESSAGE

VARCHAR

Error message, if the statement returned an error.

STATE

VARCHAR

Status of the alert. This can be one of the following: . SCHEDULED: The alert will execute at the time specified by the SCHEDULED_TIME column. . EXECUTING: The condition or action of the alert is currently executing. . FAILED: The alert failed. Either the alert condition or alert action encountered an error that prevented it from being executed. . CANCELLED: The alert execution was cancelled (e.g. when the alert is suspended). . CONDITION_FALSE: The condition was evaluated successfully but returned no data. As a result, the action was not executed. . CONDITION_FAILED: The evaluation of the condition failed. For details on the failure, check the ERROR_CODE and ERROR_MESSAGE columns. . ACTION_FAILED: The condition was evaluated successfully, but the execution of the action failed. For details on the failure, check the ERROR_CODE and ERROR_MESSAGE columns. . TRIGGERED: The condition was evaluated successfully, and the action was executed successfully.

SCHEDULED_TIME

TIMESTAMP_LTZ

Time when the alert is/was scheduled to start running. Note that we make a best effort to ensure absolute precision, but only guarantee that alerts do not execute before the scheduled time.

COMPLETED_TIME

TIMESTAMP_LTZ

Time when the alert completed, or NULL if SCHEDULED_TIME is in the future or if the alert is still running.

DATABASE_ID

NUMBER

Internal/system-generated identifier for the database containing the schema.

SCHEMA_ID

NUMBER

Internal/system-generated identifier for the schema.

Usage notes¶

  • Latency for the view may be up to 45 minutes.

  • For increased performance, filter queries on the COMPLETED_TIME or SCHEDULED_TIME column.

Examples¶

Retrieve records for the 10 most recent completed alert runs:

SELECT name, condition, condition_query_id, action, action_query_id, state
FROM snowflake.account_usage.alert_history
LIMIT 10;
Copy

Retrieve records for alert runs completed in the past hour:

SELECT name, condition, condition_query_id, action, action_query_id, state
FROM snowflake.account_usage.alert_history
WHERE COMPLETED_TIME > DATEADD(hours, -1, CURRENT_TIMESTAMP());
Copy