- Schema:
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. |
ACTION |
VARCHAR |
The 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. |
CONDITION |
VARCHAR |
The 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. |
ERROR_CODE |
NUMBER |
Error code, if the alert 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 alert returned an error. |
STATE |
VARCHAR |
Status of the alert. This can be one of the following:
|
SCHEDULED_TIME |
TIMESTAMP_LTZ |
Time when the scheduled 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. |
SCHEDULED_FROM |
VARCHAR |
Specifies what initiated the alert. The column contains one of the following values:
|
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;
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());