Integrating Snowflake usage with Dagster+ Insights#
External metrics, such as Snowflake credits, can be integrated into the Dagster Insights UI. The dagster-cloud package contains utilities for capturing and submitting external metrics about data operations to Dagster+ via an API.
Snowflake credentials which have access to the snowflake.account_usage.query_history table. For more information on granting access to this table, see the Snowflake documentation.
The first step is to replace any existing Snowflake resources with InsightsSnowflakeResource. This resource is a drop-in replacement for the SnowflakeResource resource, but it also emits Snowflake usage metrics to the Dagster+ Insights API.
Step 2: Create a metrics ingestion pipeline in Dagster#
The second step is to create a Dagster pipeline that joins asset observation events with the Snowflake query history and calls the Dagster+ ingestion API. Snowflake usage information is available at a delay, so this pipeline will run on a schedule to ingest Snowflake usage information from the previous hour.
Note that you only need to create this pipeline in a single code location per deployment, even if you have assets in multiple code locations.
To do this, you'll need a Snowflake resource (InsightsSnowflakeResource) that can query the snowflake.account_usage.query_history table. You can set up the ingestion pipeline like the following: