Close Menu
    Trending
    • Roleplay AI Chatbot Apps with the Best Memory: Tested
    • Top Tools and Skills for AI/ML Engineers in 2025 | by Raviishankargarapti | Aug, 2025
    • PwC Reducing Entry-Level Hiring, Changing Processes
    • How to Perform Comprehensive Large Scale LLM Validation
    • How to Fine-Tune Large Language Models for Real-World Applications | by Aurangzeb Malik | Aug, 2025
    • 4chan will refuse to pay daily UK fines, its lawyer tells BBC
    • How AI’s Defining Your Brand Story — and How to Take Control
    • What If I Had AI in 2020: Rent The Runway Dynamic Pricing Model
    AIBS News
    • Home
    • Artificial Intelligence
    • Machine Learning
    • AI Technology
    • Data Science
    • More
      • Technology
      • Business
    AIBS News
    Home»Machine Learning»Automating Snowflake Resource Monitor Management | by Athavale Mandar | Aug, 2025
    Machine Learning

    Automating Snowflake Resource Monitor Management | by Athavale Mandar | Aug, 2025

    Team_AIBS NewsBy Team_AIBS NewsAugust 14, 2025No Comments3 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    Share
    Facebook Twitter LinkedIn Pinterest Email


    Automating Snowflake Useful resource Monitor Administration

    Press enter or click on to view picture in full dimension

    Managing Snowflake useful resource quotas effectively is essential for price management and efficiency optimization. On this article, I’ll stroll you thru a totally automated resolution utilizing Snowflake’s native options, together with tagging, warehouse metering historical past, Cortex ML forecasting, and duties. It will assist to dynamically replace useful resource monitor quotas for digital warehouses primarily based on historic utilization patterns each month.

    To start, we categorize Snowflake warehouses by surroundings utilizing tags. This helps us phase utilization and apply environment-specific quotas.

    -- Instance: Tagging warehouses
    CREATE DATABASE SAMPLE_DB;
    CREATE SCHEMA SAMPLE_DB.SAMPLE_SCHEMA;
    CREATE TAG SAMPLE_DB.SAMPLE_SCHEMA.ENVIRONMENT ALLOWED_VALUES = ('DEV','UAT','PRD');
    ALTER WAREHOUSE WH_DEV SET TAG SAMPLE_DB.SAMPLE_SCHEMA.ENVIRONMENT = 'DEV';
    ALTER WAREHOUSE WH_UAT SET TAG SAMPLE_DB.SAMPLE_SCHEMA.ENVIRONMENT = 'UAT';
    ALTER WAREHOUSE WH_PRD SET TAG SAMPLE_DB.SAMPLE_SCHEMA.ENVIRONMENT = 'PRD';

    This tagging permits us to filter and analyze utilization knowledge by surroundings (DEV, UAT, PRD) in subsequent steps.

    We use the WAREHOUSE_METERING_HISTORY view to extract credit score consumption knowledge. The aim is to construct a month-level view of utilization per surroundings for the previous 12 months.

    Not too long ago, we began encountering points utilizing views instantly with ML.FORECAST. A help case is underway and I’ll replace the article as quickly as Snowflake engineering staff fixes it. As a workaround, we switched to TRANSIENT tables to retailer the coaching knowledge.

    -- Creating transient desk for coaching knowledge
    CREATE OR REPLACE TRANSIENT TABLE SAMPLE_DB.SAMPLE_SCHEMA.WH_DEV_USAGE_TRAINING AS
    SELECT
    B.TAG_VALUE AS ENVIRONMENT,
    TO_TIMESTAMP_NTZ(DATE_TRUNC('MONTH', A.START_TIME)) AS USAGE_MONTH,
    SUM(A.CREDITS_USED) AS CREDITS
    FROM SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY A
    INNER JOIN SNOWFLAKE.ACCOUNT_USAGE.TAG_REFERENCES B
    ON A.WAREHOUSE_NAME = B.OBJECT_NAME
    AND B.TAG_NAME = 'ENVIRONMENT' AND B.OBJECT_DELETED IS NULL
    AND B.DOMAIN = 'WAREHOUSE' AND B.TAG_VALUE = 'DEV'
    WHERE A.START_TIME >= DATEADD(MONTH, -12, CURRENT_TIMESTAMP())
    GROUP BY ALL;

    --Repeat these steps for UAT and PRD

    ⚠️ Be aware: Pay shut consideration to timestamp codecs and guarantee constant truncation to month-level granularity.

    Now we use SNOWFLAKE.ML.FORECAST to foretell credit score consumption for the present month. The forecast length dynamically adjusts primarily based on the variety of days within the month (e.g., 28 for February, 31 for August).

    CREATE OR REPLACE SNOWFLAKE.ML.FORECAST SAMPLE_DB.SAMPLE_SCHEMA.FR_DEV_WH(
    INPUT_DATA => SYSTEM$REFERENCE('TABLE', 'SAMPLE_DB.SAMPLE_SCHEMA.WH_DEV_USAGE_TRAINING'),
    TIMESTAMP_COLNAME => 'USAGE_MONTH',
    TARGET_COLNAME => 'CREDITS'
    )'';

    -- Instance: Forecasting for present month
    CALL SAMPLE_DB.SAMPLE_SCHEMA.FR_DEV_WH!FORECAST(FORECASTING_PERIODS => 31);

    This generates day by day forecasts which we later combination to find out month-to-month quotas.

    We sum the forecasted credit by surroundings and use these values to replace or create useful resource screens.

    -- Creating useful resource screens
    -- Instance for DEV
    CREATE OR REPLACE RESOURCE MONITOR RM_DEV
    WITH CREDIT_QUOTA = (SELECT SUM($3) FROM TABLE(RESULT_SCAN(LAST_QUERY_ID())),
    TRIGGERS ON 80 PERCENT DO NOTIFY
    TRIGGERS ON 90 PERCENT DO NOTIFY
    TRIGGERS ON 100 PERCENT DO SUSPEND;
    --You should use question output as credit score quota worth as a substitute of precise SQL question

    Repeat for UAT and PRD environments.

    Now since we have now forecasted the credit score quota, it’s time to put it into motion. To do that, we have to alter the warehouse with resource_monitor

    ALTER WAREHOUSE DEV1_S_VW set RESOURCE_MONITOR = RM_DEV;
    ALTER WAREHOUSE DEV2_S_VW set RESOURCE_MONITOR = RM_DEV;
    ALTER WAREHOUSE WH_DEV set RESOURCE_MONITOR = RM_DEV;
    ALTER WAREHOUSE UAT1_S_VW set RESOURCE_MONITOR = RM_UAT;
    ALTER WAREHOUSE UAT2_S_VW set RESOURCE_MONITOR = RM_UAT;
    ALTER WAREHOUSE WH_UAT set RESOURCE_MONITOR = RM_UAT;
    ALTER WAREHOUSE PRD1_S_VW set RESOURCE_MONITOR = RM_PRD;
    ALTER WAREHOUSE PRD2_S_VW set RESOURCE_MONITOR = RM_PRD;
    ALTER WAREHOUSE WH_PRD set RESOURCE_MONITOR = RM_PRD;

    To automate this course of month-to-month, we schedule the process utilizing a Snowflake Activity. Since ML forecasting might be compute-intensive, we advocate utilizing a bigger warehouse.

    -- Creating the duty
    CREATE OR REPLACE TASK TASK_UPDATE_RESOURCE_MONITOR
    WAREHOUSE = BIG_WH
    SCHEDULE = 'USING CRON 0 0 1 * * UTC' -- Runs on 1st of each month
    AS
    CALL UPDATE_RESOURCE_MONITOR_PROCEDURE();



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleDynamic Line Rating: A Solution to Grid Congestion
    Next Article I Tested Promptchan Clone AI for 1 Month
    Team_AIBS News
    • Website

    Related Posts

    Machine Learning

    Top Tools and Skills for AI/ML Engineers in 2025 | by Raviishankargarapti | Aug, 2025

    August 22, 2025
    Machine Learning

    How to Fine-Tune Large Language Models for Real-World Applications | by Aurangzeb Malik | Aug, 2025

    August 22, 2025
    Machine Learning

    Questioning Assumptions & (Inoculum) Potential | by Jake Winiski | Aug, 2025

    August 22, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Top Posts

    Roleplay AI Chatbot Apps with the Best Memory: Tested

    August 22, 2025

    I Tried Buying a Car Through Amazon: Here Are the Pros, Cons

    December 10, 2024

    Amazon and eBay to pay ‘fair share’ for e-waste recycling

    December 10, 2024

    Artificial Intelligence Concerns & Predictions For 2025

    December 10, 2024

    Barbara Corcoran: Entrepreneurs Must ‘Embrace Change’

    December 10, 2024
    Categories
    • AI Technology
    • Artificial Intelligence
    • Business
    • Data Science
    • Machine Learning
    • Technology
    Most Popular

    Private Equity Firms Must Embrace These Technologies to Stay Competitive

    March 13, 2025

    Battle of the Ducks. DuckDB vs Fireducks: the ultimate… | by Thomas Reid | Jan, 2025

    January 28, 2025

    Workday: Data Breach, Hack Exposes Personal Information

    August 19, 2025
    Our Picks

    Roleplay AI Chatbot Apps with the Best Memory: Tested

    August 22, 2025

    Top Tools and Skills for AI/ML Engineers in 2025 | by Raviishankargarapti | Aug, 2025

    August 22, 2025

    PwC Reducing Entry-Level Hiring, Changing Processes

    August 22, 2025
    Categories
    • AI Technology
    • Artificial Intelligence
    • Business
    • Data Science
    • Machine Learning
    • Technology
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • About us
    • Contact us
    Copyright © 2024 Aibsnews.comAll Rights Reserved.

    Type above and press Enter to search. Press Esc to cancel.