WH usage report
4 0
Read Time:1 Minute, 37 Second

Efficient management of Snowflake resources is crucial for optimizing performance and cost. One of the key aspects is monitoring warehouse usage. In this blog post, we’ll explore a use case where we automate the reporting of warehouse usage and send detailed weekly summaries via email. Our Organization is a data-driven organization relying heavily on Snowflake for its data warehousing needs. The company uses multiple warehouses for different environments such as development, testing, and production. To ensure optimal usage and cost management, the IT team needs to monitor the credit usage of these warehouses on a weekly basis.

Objective: Automate the generation and distribution of a weekly report that details the credit usage of specified warehouses, compares it with the previous week, and highlights any significant changes.

Solution: We’ll create a Snowflake stored procedure that:

  1. Queries the warehouse metering history to get the weekly credit usage for the past 28 days.
  2. Constructs an HTML email report summarizing the warehouse usage and changes.
  3. Sends the report to the IT team’s email address

Technical implementation:

Step 1: Create the Stored Procedure

We’ll start by creating a stored procedure in Snowflake. This procedure will execute a query to gather the necessary data, format it into an HTML table, and send it via email.

Step 2: Schedule the Stored Procedure

To automate this process, we’ll use Snowflake Tasks to schedule the stored procedure to run weekly.

CREATE OR REPLACE TASK SEND_WH_INFO_MAIL_TASK
WAREHOUSE = my_warehouse
SCHEDULE = 'USING CRON 0 0 * * 0 UTC' -- Every Sunday at midnight UTC
AS
CALL SEND_WH_INFO_MAIL();

Output:

WH usage report

Benefits

  1. Automation: The entire process is automated, ensuring regular and timely reporting without manual intervention.
  2. Efficiency: IT teams can quickly identify usage patterns, trends, and anomalies, enabling proactive management of resources.
  3. Cost Management: By monitoring usage, the team can make informed decisions on scaling and resource allocation, potentially reducing costs.

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

Your email address will not be published. Required fields are marked *