What you will be able to do
- Write a scheduled CREATE ALERT whose condition checks a model monitor metric against a threshold
- Raise governance-rule violations from data metric function expectation results
- Turn inference-service metrics into latency and availability alerts
- Assemble audit evidence of who called which model version, and when, from access history and inference logs
1.How a Snowflake alert is built
Monitoring only helps if someone sees the result. A Snowflake alert is a schema-level object with three parts: a condition, an action, and a schedule for evaluating the condition. The condition is written as IF (EXISTS (...)) and may use a SELECT, SHOW or CALL statement. If it returns one or more rows, the THEN action runs. That action is usually SYSTEM$SEND_EMAIL or SYSTEM$SEND_SNOWFLAKE_NOTIFICATION.
CREATE OR REPLACE ALERT alert_new_rows
WAREHOUSE = my_warehouse
SCHEDULE = '1 MINUTE'
IF (EXISTS (
SELECT *
FROM my_table
WHERE row_timestamp BETWEEN SNOWFLAKE.ALERT.LAST_SUCCESSFUL_SCHEDULED_TIME()
AND SNOWFLAKE.ALERT.SCHEDULED_TIME()
))
THEN CALL SYSTEM$SEND_EMAIL(...);Alerts come in two kinds. An alert on a schedule runs every n minutes or on a cron expression and evaluates its condition against all of the data. An alert on new data runs only when rows arrive and sees only those rows. Because of that, its condition is restricted: one regular table, view or event table in the FROM clause, with change tracking enabled, and no CTEs, joins, DML or stored-procedure calls.
Compute and privileges come next. A serverless alert sizes its own compute. A warehouse-backed alert costs at least one minute of warehouse time per run, even when all it does is send an email, so alerts that fire rarely are cheaper serverless. The creating role needs EXECUTE ALERT on the account, which only ACCOUNTADMIN can grant. It also needs EXECUTE MANAGED ALERT for a serverless alert or USAGE on the alert's warehouse, plus USAGE and CREATE ALERT on the schema.
Checkpoint 1 of 5· Check yourself
You want an alert that emails the team when daily RMSE goes above a threshold. The condition is SELECT ... FROM TABLE(MODEL_MONITOR_PERFORMANCE_METRIC('MY_MONITOR', 'RMSE', ...)) WHERE METRIC_VALUE > 5. Which alert design works?
In an alert on new data, the FROM clause can name only one regular table, view or event table, with change tracking on. Stored-procedure calls, joins and CTEs are not allowed either. A threshold query on a model monitor table function doesn't meet those rules, so it has to run as an alert on a schedule.
“In the SELECT statement, the FROM clause can specify only one regular table, view, or event table.”Source: docs.snowflake.com
2.Alerting on accuracy and drift thresholds
A degradation alert sends a threshold query to a channel. The condition selects from MODEL_MONITOR_PERFORMANCE_METRIC (or MODEL_MONITOR_DRIFT_METRIC for a drift threshold) and filters on METRIC_VALUE. For example, F1_SCORE below 0.7 or POPULATION_STABILITY_INDEX above the team's tolerance. If any window breaches, rows come back and the email goes out. Schedule the alert to match the monitor: when metrics are aggregated daily, checking every minute adds cost and catches nothing extra.
Bound the window, or the alert keeps firing. The metric functions default to the last 60 days. A scheduled condition that omits the range finds the same bad day every run and emails about it for two months. Passing SNOWFLAKE.ALERT.LAST_SUCCESSFUL_SCHEDULED_TIME() and SNOWFLAKE.ALERT.SCHEDULED_TIME() as the start and end limits each run to what is new. Calling those functions requires the SNOWFLAKE.ALERT_VIEWER database role.
Alerts can fail too. If you set SUSPEND_ALERT_AFTER_NUM_FAILURES, an alert suspends after that many consecutive failed or timed-out runs. SHOW ALERTS then reports was_auto_suspended = TRUE, and the alert stays silent until someone runs ALTER ALERT ... RESUME. Check that state when a quiet period looks too good.
Checkpoint 2 of 5· Check yourself
A scheduled alert emails the team every morning about the same day, 3 October, when F1_SCORE fell below 0.7, even though every day since has been above 0.7. Its condition calls MODEL_MONITOR_PERFORMANCE_METRIC with only the monitor name, metric and '1 DAY'. What is causing the repeat emails?
If you leave out the range, a version monitor's metric function returns the last 60 days. Each scheduled run therefore finds the same breaching window and fires again. To check only new windows, pass SNOWFLAKE.ALERT.LAST_SUCCESSFUL_SCHEDULED_TIME() and SNOWFLAKE.ALERT.SCHEDULED_TIME() as start_time and end_time. Switching to an alert on new data won't work, because its condition can't read a table function.
“The default value is 60 days before the current time for model version monitors”Source: docs.snowflake.com
3.Raising governance-rule violations from DMF expectations
Governance rules for ML data, such as no more than ten nulls in a training feature, are written as expectations on Data Metric Functions and expectations. Expectations only record results. Nothing notifies anyone until an alert or notification setting is attached.
The view SNOWFLAKE.LOCAL.DATA_QUALITY_MONITORING_EXPECTATION_STATUS holds one row for every evaluation of a DMF that has an expectation, with table_name, metric_name, value, expectation_name and expectation_violated. A governance alert is a scheduled alert whose condition selects rows with expectation_violated = TRUE since the last run. The action emails the data steward. The alert's role needs SNOWFLAKE.DATA_QUALITY_MONITORING_VIEWER or SNOWFLAKE.DATA_QUALITY_MONITORING_ADMIN to read the view.
NULL in expectation_violated means the evaluation itself failed. A condition that tests only for TRUE stays quiet while the rule goes unchecked, so a careful governance alert also catches NULL.
There is also a built-in route that needs no alert. Setting DATA_QUALITY_MONITORING_SETTINGS on a database sends a notification whenever any expectation in it is violated, by email or by webhook, with a cooldown setting. Use database-level notifications for broad coverage, and turn them off for individual associations that are too noisy. Use a custom alert when one rule needs its own routing, wording or schedule.
Checkpoint 3 of 5· Check yourself
Last week a training feature broke a data-quality expectation on its DMF (no more than ten nulls). The expectation recorded the violation, but nobody was told. What is missing?
Expectations only record results. A notification goes out only when an alert, with its condition, action and schedule, or a database-level notification setting is attached to act on those results.
“Your data fails to comply with a particular business rule that you have set up.”Source: docs.snowflake.com
4.Turning serving metrics into latency and availability alerts
Model quality is half the picture. A model that is perfectly accurate but times out still fails its callers. Inference services publish Serving metrics for inference services (latency, throughput, availability) to the account event table. Operational monitoring turns those metrics into thresholds that alert someone.
-- Retrieve metrics using the service helper function
SELECT *
FROM TABLE(mydb.myschema.my_model_service!SPCS_GET_METRICS())
WHERE
timestamp > dateadd(hour, -1, current_timestamp())
AND instance_id = 0 -- choose all instances or one particular
AND container_name = 'model-inference';The helper is a table function, so a latency threshold built on it belongs in a scheduled alert. The event table itself is a different case. Metric records there have RECORD_TYPE = 'METRIC', and an event table is a valid single source for an alert on new data. That lets a request-rate or latency condition run only when new records arrive. For services with real-time inference logging, captured records include snow.model_serving.response.code, so a spike in 5xx responses is a direct availability signal.
Availability depends on configuration as well as alerting. With the default min_instances=0, a service auto-suspends after 30 minutes idle, and the next request waits for a cold start. An alert will flag that as an outage even though it is configured behaviour. Production services should keep min_instances at 1 or more. To survive node failures, Snowflake recommends over-provisioning by 50% or running at least 3 instances, whichever is higher.
Checkpoint 4 of 5· Check yourself
An on-call team wants a latency check on a model inference service that runs only when new metric records arrive, not on a fixed timer. Which condition can an alert on new data hold?
In an alert on new data, the FROM clause can name only one regular table, view or event table, and change tracking must be on. Reading metric records straight from the event table fits that rule. The helper is a table function, so it needs a scheduled alert. Joins and CTEs are not allowed in an alert on new data.
“In the SELECT statement, the FROM clause can specify only one regular table, view, or event table.”Source: docs.snowflake.com
5.Auditing who called which model version, and when
In regulated industries, the questions after an incident are who ran the model, which version, on what data, and when. The ACCESS_HISTORY view in ACCOUNT_USAGE answers most of them for SQL access. Each row is one statement, with query_id, user_name and query_start_time. direct_objects_accessed lists the UDFs, stored procedures, tables, views and columns named in the query. base_objects_accessed traces those back to the underlying sources, and policies_referenced records any masking or row access policy that was enforced.
Three details trip up auditors. The view keeps 365 days, so evidence that must be kept longer has to be copied out on a schedule. A request sent through the Python connector or the SQL API returns one parent query ID, and you find the individual statements by filtering on parent_query_id. Finally, not every QUERY_HISTORY row has a matching ACCESS_HISTORY row, so an audit that joins the two must expect gaps.
REST calls to an inference service are recorded somewhere else. Autocaptured inference logs tag each request with snow.model.version.name, snow.model_serving.function.name, the request timestamp and the response code. This ties every real-time call to an exact version. The captured data outlives the service and gateway, but deleting the model object permanently deletes it, which matters before anyone cleans up an old model. To trace in the other direction, from the model back to the training data that produced it, use Snowflake Lineage (Snowsight graph and GET_LINEAGE). Together, lineage and access history form an audit chain from source data to model to every call made against it.
| Question | Evidence source | Field |
|---|---|---|
| Who ran the SQL statement, and when | ACCESS_HISTORY | user_name, query_start_time |
| Which functions, procedures and tables a statement touched | ACCESS_HISTORY | direct_objects_accessed, base_objects_accessed |
| Which governance policies were enforced | ACCESS_HISTORY | policies_referenced |
| Which model version served a real-time request | Autocaptured inference logs | snow.model.version.name |
| Whether the request succeeded | Autocaptured inference logs | snow.model_serving.response.code |
Checkpoint 5 of 5· Check yourself
An auditor asks which model version answered a specific real-time REST request to an inference service last month. Where is that recorded?
REST calls to an inference service are not SQL statements, so the evidence is in the autocaptured inference logs. Each record carries the model version name, the function name, the request timestamp and the response code.
“snow.model.version.name | Name of the model version.”Source: docs.snowflake.com
Sources
(9)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.https://docs.snowflake.com/en/user-guide/alertsOfficial docs
“A Snowflake alert is a schema-level object that specifies:”
↩︎ How a Snowflake alert is built“even a simple action that sends an email notification incurs at least one minute of warehouse cost.”
↩︎ How a Snowflake alert is built“This privilege can only be granted by a user with the ACCOUNTADMIN role.”
↩︎ How a Snowflake alert is built“The condition of the alert is evaluated on all of the data”
↩︎ Alerting on accuracy and drift thresholds“LAST_SUCCESSFUL_SCHEDULED_TIME returns the timestamp representing when the last successfully evaluated alert was scheduled.”
↩︎ Alerting on accuracy and drift thresholds“alerts are automatically suspended after the specified number of consecutive alert runs that either fail or time out”
↩︎ Alerting on accuracy and drift thresholds“In the SELECT statement, the FROM clause can specify only one regular table, view, or event table.”
↩︎ Exam trap 1“In the SELECT statement, the FROM clause can specify only one regular table, view, or event table.”
↩︎ Checkpoint“In the SELECT statement, the FROM clause can specify only one regular table, view, or event table.”
↩︎ Prediction“Your data fails to comply with a particular business rule that you have set up.”
↩︎ Checkpoint“In the SELECT statement, the FROM clause can specify only one regular table, view, or event table.”
↩︎ Checkpoint - 2.
“If the statement returns one or more rows, the action for the alert is executed.”
↩︎ How a Snowflake alert is built“To send a notification, you can call the SYSTEM$SEND_EMAIL or SYSTEM$SEND_SNOWFLAKE_NOTIFICATION stored procedure.”
↩︎ How a Snowflake alert is built - 3.
“The default value is 60 days before the current time for model version monitors”
↩︎ Alerting on accuracy and drift thresholds - 4.https://docs.snowflake.com/en/sql-reference/local/data_quality_monitoring_expectation_statusOfficial docs
“This view displays a row for every time a data metric function (DMF) with an expectation was run in your account.”
↩︎ Raising governance-rule violations from DMF expectations“A NULL value indicates the evaluation of the expectation failed.”
↩︎ Raising governance-rule violations from DMF expectations“A NULL value indicates the evaluation of the expectation failed.”
↩︎ Exam trap 2 - 5.
“You enable notifications at the database level.”
↩︎ Raising governance-rule violations from DMF expectations - 6.https://docs.snowflake.com/en/developer-guide/snowflake-ml/inference/service-managementOfficial docs
“Model serving services emit performance and health metrics that can help you monitor resource utilization, request rates, latency, and other operational characteristics.”
↩︎ Turning serving metrics into latency and availability alerts“The default min_instances=0 setting allows the service to auto-suspend after 30 minutes of inactivity.”
↩︎ Turning serving metrics into latency and availability alerts“Snowflake recommends over-provisioning by 50% or maintaining a minimum of 3 instances (whichever is higher).”
↩︎ Turning serving metrics into latency and availability alerts - 7.https://docs.snowflake.com/en/developer-guide/snowflake-ml/inference/auto-capture-inference-logsOfficial docs
“Response code from the inference service (for example, 200, 5xx).”
↩︎ Turning serving metrics into latency and availability alerts“Warning: Deleting the Model object will permanently delete all associated inference data.”
↩︎ Auditing who called which model version, and when“snow.model.version.name | Name of the model version.”
↩︎ Checkpoint - 8.
“The records in these views facilitate regulatory compliance auditing”
↩︎ Auditing who called which model version, and when“Records in the Account Usage QUERY_HISTORY view do not always get recorded in the ACCESS_HISTORY view.”
↩︎ Exam trap 3 - 9.
“data objects such as user-defined functions (that is, UDFs and UDTFs), stored procedures, tables, views, and columns directly named in the query”
↩︎ Auditing who called which model version, and when“within the last 365 days (1 year)”
↩︎ Auditing who called which model version, and when