Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Monitor SQL Server Performance on Azure Local

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Monitoring SQL Server performance on Azure Local (formerly Azure Stack HCI) is essential for keeping your databases responsive and avoiding unexpected outages. This guide walks you through the key metrics to watch, the built-in tools to use, and the steps to set up a practical monitoring routine. You'll learn how to track CPU, memory, disk I/O, and query performance, and how to act on the data you collect.

What You'll Need

  • Access to the Azure Local cluster (Azure Stack HCI) where SQL Server is deployed.
  • Permissions to run SQL Server Management Studio (SSMS) or Azure Data Studio.
  • Administrator rights on the Windows Server hosts to configure Performance Monitor or Log Analytics.
  • An Azure subscription if you plan to use Azure Monitor for advanced alerting.

Step-by-Step

  1. Start with SQL Server's built-in reports. Open SSMS, connect to your SQL Server instance, right-click the server name in Object Explorer, choose Reports > Standard Reports, and select Performance – Top Queries by CPU or Disk Usage. These give an immediate snapshot of what's consuming resources.
  2. Check the core wait statistics. Run this query to see what SQL Server is waiting on most:
    SELECT wait_type, wait_time_ms, signal_wait_time_ms, waiting_tasks_count FROM sys.dm_os_wait_stats ORDER BY wait_time_ms DESC;
    High PAGEIOLATCH waits indicate disk bottlenecks; LCK waits point to blocking; CXCONSUMER suggests parallelism issues.
  3. Monitor CPU usage. In Performance Monitor (perfmon) on the host, add counters: Processor Information\% Processor Time for the whole system and SQL Server:Buffer Manager\Buffer Cache Hit Ratio. If the cache hit ratio stays above 95%, memory is likely adequate.
  4. Track memory pressure. Query sys.dm_os_performance_counters for Target Server Memory (KB) and Total Server Memory (KB). If Total is consistently close to Target, SQL Server wants more memory. Also watch Page Life Expectancy; values below 300 seconds often mean memory pressure.
  5. Measure disk latency. In perfmon, add PhysicalDisk\Avg. Disk sec/Read and Avg. Disk sec/Write. For SQL Server data files, sustained values above 20 ms for reads or writes are a red flag. On Azure Local, also check Storage Spaces Direct health via Windows Admin Center.
  6. Identify blocking queries. Run sp_who2 or use the Activity Monitor in SSMS. Look for sessions with a BLK value. To dig deeper, use sys.dm_exec_requests and sys.dm_exec_sql_text to see the blocking query text.
  7. Set up Azure Monitor (optional but recommended). In the Azure portal, navigate to your Azure Local resource, enable Azure Monitor for VMs, and install the SQL Server monitoring solution. This gives you pre-built dashboards for database health, wait stats, and deadlocks.
  8. Create custom alerts. In Azure Monitor, set alerts for metrics like CPU > 85% for 10 minutes, disk latency > 20 ms, or SQL Server errors. Use Log Analytics queries to trigger on specific events, such as deadlocks or severe errors.
  9. Schedule a regular review. Set aside 30 minutes weekly to review the collected data. Look at trends, not just spikes. Compare this week's wait stats to last week's to spot gradual degradation.

Common Mistakes

  • Ignoring the host-level metrics. SQL Server performance is tied to the physical host. If the host's CPU or memory is saturated, SQL Server will suffer even if its own counters look fine.
  • Focusing only on CPU. Many performance issues are I/O or memory related. Always check wait stats first to see where the bottleneck actually is.
  • Using default thresholds blindly. A 20 ms disk latency threshold is a guideline. Some workloads (like OLTP) may need lower, while others (like reporting) can tolerate higher. Establish a baseline for your environment.
  • Forgetting to monitor tempdb. Tempdb contention can cause severe slowdowns. Watch tempdb data file sizes and wait type PAGELATCH.
  • Not setting up alerts. Reactive monitoring is better than none, but proactive alerts let you fix issues before users notice.

Tips

  • Use the Query Store in SQL Server. It captures query performance history, making it easy to spot regressions after changes.
  • On Azure Local, take advantage of Storage Spaces Direct. Check the health of the storage pool regularly via Windows Admin Center – a degraded pool will hurt SQL Server I/O.
  • Collect a baseline during a normal workload period. Compare future metrics to this baseline to detect anomalies early.
  • Use sp_Blitz or sp_BlitzCache (free scripts from Brent Ozar) for a quick health check. They summarize common issues in a readable format.
  • Consider using the SQL Server Performance Dashboard reports available in SSMS for a visual overview.

Troubleshooting

  • If you see high CPU but no obvious query: Check for background processes like index rebuilds or statistics updates. Use sys.dm_exec_requests to see what's running, and look at sys.dm_exec_query_stats for cumulative CPU.
  • If disk latency is high but the storage is healthy: Check if the SQL Server database files are on the same volume as the OS or other VMs. Move data files to a dedicated volume. Also verify that the VM's virtual disk is configured with the correct caching mode.
  • If memory pressure persists: Review sys.dm_os_memory_clerks to see which component is using memory. Sometimes it's not SQL Server but the host. If the host is low on memory, consider adding RAM or moving other VMs.
  • If blocking is frequent: Look at the application code. Often, a missing index or a long transaction causes locks. Use sys.dm_db_index_usage_stats to find unused indexes and sys.dm_db_missing_index_details to find missing ones.
  • If Azure Monitor shows no data: Check that the Log Analytics agent is installed and connected. Verify the workspace is in the same region as your Azure Local resource. Also confirm that the SQL Server solution is enabled.

Frequently Asked Questions

What is the most important metric to monitor?

Wait statistics are the best starting point. They tell you what SQL Server is waiting on, which directly points to the bottleneck – CPU, I/O, or locks.

How often should I check performance?

For critical systems, set up real-time alerts and review trends weekly. For less critical ones, a monthly review may suffice.

Can I use the same methods on Azure SQL Managed Instance?

Some tools like SSMS reports and DMVs work similarly, but Azure SQL Managed Instance doesn't expose host-level counters. Use Azure Monitor's built-in SQL analytics instead.

Do I need a separate tool for monitoring?

No. SQL Server Management Studio, Performance Monitor, and Azure Monitor cover most needs. Third-party tools add convenience but aren't required.

What does Page Life Expectancy mean?

It's the number of seconds a page stays in the buffer pool. A low value (under 300) suggests memory pressure, but it's workload-dependent.

How do I monitor deadlocks?

Enable the deadlock trace flags (1222 or 1204) or use the system_health session in Extended Events. Azure Monitor also captures deadlock events.