Snowflake annotations
Annotations in Grafana allow you to overlay event data on your graphs, making it easier to correlate metrics with specific events such as query failures, warehouse scaling, or data loading operations. For an overview of annotations, refer to Annotate visualizations.
Before you begin
- Ensure you have configured the Snowflake data source.
- Your dashboard must already be saved before creating annotations.
- Annotations only work with the following visualization types: time series, state timeline, and candlestick.
Annotation query format
Your annotation query must return at least a time column. Optional columns include:
To limit results to the dashboard time range, use the $__timeFilter macro in your WHERE clause. For more information, refer to Macros.
Create an annotation
To create an annotation query:
- Open your dashboard and click Dashboard settings (gear icon).
- Select Annotations in the left menu.
- Click Add annotation query.
- Select your Snowflake data source.
- Enter your SQL query.
- Click Save dashboard.
Annotation examples
The following examples show common annotation patterns for Snowflake. They use the $__timeFilter macro to limit results to the dashboard time range.
Note
These examples query the
SNOWFLAKE.ACCOUNT_USAGEschema. Access to these views requires theACCOUNTADMINrole, or a role that has been granted theIMPORTED PRIVILEGESprivilege on theSNOWFLAKEdatabase. For more information, refer to Enabling the SNOWFLAKE database usage for other roles.
Track failed queries
Show when queries have failed to help correlate with performance issues:
SELECT
start_time AS time,
CONCAT('Query Failed: ', query_type) AS title,
CONCAT('Error: ', error_message, '\nWarehouse: ', warehouse_name,
'\nUser: ', user_name) AS text,
'query-failure,error' AS tags
FROM snowflake.account_usage.query_history
WHERE $__timeFilter(start_time)
AND execution_status = 'FAIL'
ORDER BY start_timeTrack warehouse scaling events
Monitor when warehouses scale up or down:
SELECT
timestamp AS time,
CONCAT('Warehouse: ', warehouse_name) AS title,
CONCAT('Event: ', event_name,
'\nCluster number: ', cluster_number) AS text,
CONCAT('warehouse,', warehouse_name) AS tags
FROM snowflake.account_usage.warehouse_events_history
WHERE $__timeFilter(timestamp)
AND event_name IN ('RESIZE_WAREHOUSE', 'RESUME_WAREHOUSE', 'SUSPEND_WAREHOUSE', 'SPINUP_CLUSTER', 'SPINDOWN_CLUSTER')
ORDER BY timestampTrack data loading operations
Annotate when data loads complete or fail:
SELECT
last_load_time AS time,
CONCAT('Load: ', table_name) AS title,
CONCAT('Status: ', status, '\nRows loaded: ', row_count,
'\nFile: ', file_name) AS text,
CASE
WHEN status = 'LOADED' THEN 'load-success'
WHEN status = 'LOAD_FAILED' THEN 'load-failed,error'
ELSE 'load-partial'
END AS tags
FROM snowflake.account_usage.load_history
WHERE $__timeFilter(last_load_time)
ORDER BY last_load_timeTrack user login events
Monitor authentication events for security visibility:
SELECT
event_timestamp AS time,
CONCAT('Login: ', user_name) AS title,
CONCAT('Client: ', client_ip, '\nAuth method: ', first_authentication_factor,
'\nStatus: ', is_success) AS text,
CASE
WHEN is_success = 'YES' THEN 'login-success'
ELSE 'login-failed,security'
END AS tags
FROM snowflake.account_usage.login_history
WHERE $__timeFilter(event_timestamp)
ORDER BY event_timestampTrack task executions
Monitor scheduled task completions and failures:
SELECT
scheduled_time AS time,
query_start_time AS timeEnd,
CONCAT('Task: ', name) AS title,
CONCAT('Database: ', database_name, '.', schema_name,
'\nState: ', state, '\nDuration: ',
DATEDIFF('second', query_start_time, completed_time), 's') AS text,
CASE
WHEN state = 'SUCCEEDED' THEN 'task-success'
WHEN state = 'FAILED' THEN 'task-failed,error'
ELSE 'task-skipped'
END AS tags
FROM snowflake.account_usage.task_history
WHERE $__timeFilter(scheduled_time)
ORDER BY scheduled_timeAnnotation display
After you configure the annotation query, annotations appear as:
- Vertical lines on your time series, candlestick, or state timeline panels
- At the timestamp specified in your query
- With hover tooltips showing the title and detailed text
- Filterable by tags (such as
query-failureorwarehouse)
Next steps
- Learn about Template variables to make your annotations dynamic.
- Refer to Annotate visualizations for more annotation options.


