Warehouse Utilization With Streamlit
Analyze Warehouse Utilization in Snowflake Notebooks with Streamlit
A notebook that generates a heatmap of warehouse usage patterns to identify peak hours that can help with cost optimization.
Here's what we're implementing to investigate the tables:
- Retrieve warehouse utilization data
- Convert table to a DataFrame
- Create an interactive slider widget
- Create a Heatmap for visualizing warehouse usage patterns
1. Retrieve warehouse utilization data
Firstly, we'll write a SQL query to retrieve warehouse utilization data.
2. Convert table to a DataFrame
Next, we'll convert the table to a Pandas DataFrame.
3. Create an Interactive slider widget
Let's create an interactive slider using Streamlit. This would allow users to select the number of days to analyze, which would filter the DataFrame.
Finally, we'll calculate the total warehouse load (TOTAL_LOAD) and format the hour display (HOUR_DISPLAY) for each record.
4. Create a Heatmap for visualizing warehouse usage patterns
Finally, we're create a heatmap using Altair. The heatmap shows the warehouse usage pattern across different hours of the day. Color intensity represents the total load and interactive tooltips showing detailed metrics for each cell.
Want to learn more?
- Snowflake Docs on Account Usage and WAREHOUSE_LOAD_HISTORY view
- More about Snowflake Notebooks
- For more inspiration on how to use Streamlit widgets in Notebooks, check out Streamlit Docs and this list of what is currently supported inside Snowflake Notebooks
- Check out the Altair User Guide for further information on customizing Altair charts