Cloud hosting services, like Microsoft Azure, provide a ton of advantages. Including, ease of use, scalability, platform-as-a-service features, and more. It also creates some unique challenges. Monitoring cloud infrastructure, applications, and Azure services is different than traditional application monitoring. In this article, we are going to cover some Azure monitoring best practices.
Overview of Azure Portal Monitoring via Azure Monitor
Microsoft now provides a centralized hub for all the built-in performance Azure metrics. Including servers, applications, and platform-as-a-service offerings that you are consuming. Azure Monitor can show you a wide array of Azure metrics. From the CPU % of a Linux server, deadlocks in a SQL database, and # of Cache Gets for Azure Redis cache.
Azure Monitor supports:
- Virtual machines
- App Services
- SQL Azure databases & pools
- Azure Redis
- Azure Storage
- … and more
Azure Monitor provides basic alerting capabilities. You can select any of the available metrics that are tracked by Azure Monitor. Basic greater than and less than thresholds can be configured. You can configure alerts to be emailed or fire off a webhook. You can create Logic apps to do more complicated things with your alerts.
Read more: Get started with Azure Monitor
How to Monitor Azure Apps & Servers
Azure Virtual Machines
Traditional monitoring tools work fine with Azure virtual machines. Including common monitoring tools like Nagios, SCOM, SolarWinds, Retrace and other common tools. Azure VMs give you complete administrative control of the server use these tools.
Azure App Services
App Services abstract away the underlying servers that your applications are running on. You do not have access to install traditional monitoring agents. Instead, there are some APM solutions that work with App Services, like Retrace. Azure Monitor can also provide some basic performance metrics.
App Service limits the ability to monitor Windows Performance Counters. For example, this makes it impossible to monitor things like .NET Garbage Collection counters. ETW is also not fully supported. Within the Azure Portal, you can access “Metrics Per Instance” to see some Windows Performance Counters. But you are limited to these and they don’t seem to show in Azure Monitor currently.
WebJobs can be used as a monitoring agent to perform some server and application monitoring functions. Retrace’s monitoring agents are deployed this way.
Azure Cloud Services
Cloud Services do not have the same limitations as App Services. Cloud Services provide administrator level access to the servers they run on. You can configure startup tasks to install monitoring agents. You should be able tuseze most traditional application monitoring tools, if you can script the install process. Azure Monitor does not provides near as many metrics as it does for App Services.
Azure diagnostics can also be used in conjunction with your Azure virtual machines, Cloud Services, and App Services. Azure diagnostics gives you access to various types of log files, crash dumps, performance counters, and other data. This data is saved to Azure storage and can optionally be pushed into Application Insights.
Read more on Azure Diagnostics: Configuring Diagnostics for Azure Cloud Services and Virtual Machines
How to Monitor SQL Azure
When SQL Azure first came it had a subset of SQL features and some limited monitoring capabilities. SQL Azure is now a very robust sibling of SQL Server. SQL Azure has some unique monitoring features but also supports most standard SQL Server DMVs. Most all standard SQL monitoring tools like SQL Sentry, Ignite and others should work with SQL Azure.
As part of Stackify Retrace, the usage and performance of all of your SQL queries are automatically tracked. Retrace can be used to identify slow and overused SQL queries. Retrace can also specific queries and alert you if they are slow.
How to Monitor Azure Service Bus
If you are using Azure Service Bus in your application, it is important that you monitor your queues. If too many messages are in your queues then you know your applications are either not working or reading the messages fast enough. Retrace can monitor individual queues so you can ensure messages are not stacking up.
You can also utilize Retrace APM functionality to profile the code in your Azure Worker Roles. You can track how often you process queued messages, how long it takes, and exactly what your code is doing.
What is the Azure Service Profiler?
The new Azure Service Profiler is a new preview service (as of 3/1/17) from Microsoft. It provides deep code level details about what your web applications are doing. It can be used with most ASP.NET applications.
Microsoft has an easy to install Site Extension for Azure App Services. It makes it very easy to use if you are also using Application Insights. It is also possible to use it without Application Insights and on virtual machines.
Read our review: Azure Service Profiler review – How does it fit in your toolbox?
Azure Application Insights
Application Insights is a basic application monitoring solution from Microsoft. It can be used in conjunction with Azure Montor to implement basic monitoring functionality within the Azure portal. App Insights can track application exceptions, SQL queries, and external HTTP queries executed by your code. It provides basic APM type functionality but is not as robust as other APM solutions like Retrace, New Relic, etc.
Azure Monitoring Tools
So noted above, not all monitoring tools work with Azure or all the different types of Azure resources. Microsoft provides some various tools that you can use and there are third party tools available as well. You may want to use a combination of Azure Monitor plus an APM solutions like Retrace for code level performance.
Some recommended Azure monitoring tools:
- Stackify Retrace
- Azure Monitor (via Azure Portal)
- Application Insights
- Microsoft OMS
Overview of Azure Monitoring with Stackify Retrace
Azure monitoring is easy with Stackify. Monitor the overall performance, metrics, errors, and logs for your applications.
How to install Stackify Retrace APM
Retrace is installed as a code level profiler and server monitoring agent. You can easily install it on Cloud Services and virtual machines. Retrace works perfectly with apps that leverage autoscaling. App Services are also supported, but are installed differently.
Using Retrace With Azure App Services
Installing Retrace APM on Azure App Services is really simple. You do not need to change any code or re-deploy your app. All you need to do is sign up for a free trial of Stackify, install our Site Extension via the Azure Portal and plug in your Stackify license key into the application settings for your app. See our docs for full details step by step. You can be up and running in a few minutes.
Monitoring Azure Application Performance
With Stackify you can monitor the performance of all of your apps in one place. We support Azure App Services, Azure Cloud Services, AWS, or any Windows Server running your ASP.NET apps.
How is your application stack performing?
Stackify makes it easy to understand how your application stack is performing. Our APM automatically recognizes all the most common .NET libraries including popular Azure features like Service Bus, DocumentDB, Azure Storage, SQL Azure, Redis and much more. This makes it easy to identify performance problems quickly.
Satisfaction scoring makes it easy to understand performance
Stackify also tracks the user satisfaction for your application based on apdex scoring. It is calculated based on response time goals you set for your application. Response time averages are easily skewed by a couple slow requests. Satisfaction scores instead bucket the performance in to “Fast”, “Sluggish”, “Too Slow”, and “Failed” requests which makes it easier to understand the relative performance. An overall score from 0 to 100 is also calculated.
Monitoring performance of each web request
View the performance of all the requests to your app. Quickly find which requests are the slowest, most used, erroring out, slow due to database calls and much more.
Find slow database queries
Stackify also tracks all of your database queries and allows you to see which ones are the slowest.
Monitoring performance of 3rd party web services
You can also see which web services you are using and how they are performing
Dissect the performance of a single web request
Stackify tracks the performance of every single ASP.NET web request on your Azure site. We don’t only monitor slow requests like some other APM solutions. Stackify can help you identify why any web request is slow or not functioning properly due to other bugs.
Find the hot spot in your code
By tracking what resource each requests uses, Stackify can help you identify why the request takes as long to load as it does. You can quickly identify slow database queries, too many queries, too many cache calls, slow web service calls, etc.
View code-level profiling traces for advanced troubleshooting
Stackify is designed to help developers fix application problems. One way do this is by tracking common methods that help developers understand the performance and behavior of their apps. We automatically track and show details like what redis keys, Azure Storage table names, queue names, database names and much more. With the addition of our optional logging module, we can even show your error and log messages inline which can add an amazing amount of debugging details to help solve problems. How amazing is that?
Troubleshoot problems with all your errors and logs
Stackify APM can automatically collect the exceptions from your applications. We can also aggregate all of your Azure App Services log messages from your apps and IIS logs. Please note that some of the following features are only available with our optional Error & Log module.
Find top application exceptions
Our error tracking module makes it easy to find your most common errors and setup monitoring for new ones and high error rates.
Aggregate all of your logs together
Accessing your raw log files on Azure App Services can be really difficult. If you are using a logging framework like NLog or log4net, you can add the Stackify appender to your web config and send all of your logs to Stackify to be fully indexed and analyzed for analysis.
Aggregate your IIS logs too!
Your IIS logs serve as a valuable audit log to track all the requests to your site. Stackify can optionally and auto-magically pick up all of your IIS logs and ship them to our log management product as well.
Log extra debug information
You can even log objects via log4net or NLog to get advanced details to help troubleshoot problems. You can then search by any of these fields on our error and log modules. Tags also make it easy to search for specific log messages and errors by subject, subsystem, or category.
Monitor Your ASP.NET Apps
Stackify is a great way to monitor the overall health of your apps including requests per minute, user satisfaction scoring, error rates, page load times and much more. We also monitor the CPU and memory usage of your applications. Below is some highlights of just some of the things you can monitor with Stackify.
Monitor Key Transactions
You can configure monitoring for specific web requests and SQL queries that are critical to the health of your application.
Monitor your Azure website URL
Stackify can also do ping type checks against your website URL or other URLs, every minute and alert you if it is too slow or returns an improper status code.
Monitor error rates
Application errors are inevitable, especially with cloud apps that are more prone to transient type errors. You also have to worry about noisy neighbors in the cloud or hiccups when Azure does their own maintenance. We highly recommend setting up some basic monitoring thresholds for error rates to let you know if your app starts throwing 500 errors a minute all of a sudden.
Got custom metrics?
Via our API and nuget package you can even log your own custom application metrics. It only takes a couple lines of code to track how often something happens or how long a certain part of your code happens. Learn more about custom metrics in our docs.
StackifyLib.Metrics.Count(“People Metrics”, “DB Query Called”);
You can then monitor those metrics with Stackify.
Monitor Azure Service Bus
If you are using Service Bus queues, we highly recommend monitoring them as well. You can monitor how many messages are in your queues to ensure they are being handled properly.
Stackify is your top choice for monitoring Azure!
Stackify is written in ASP.NET and has been hosted on Azure since 2012. You can rest assured we have top notch support for your Azure resources. Our goal is to help developers find and fix application problems quickly by combining all the data and tools they need to do so.
Note: Almost everything in this post is examples from our online sandbox account. You can access it anytime to play with our product and get a better idea of how it works at anytime.