Skip to main content
HomeTutorialsData Engineering

Getting Started with Azure Monitor: Key Features and Best Practices

Learn key features and best practices for Azure Monitor to optimize resource usage and costs, ensure compliance, and resolve performance or security issues.
Jul 2, 2024  · 11 min read

Monitoring your cloud environment is crucial for maintaining performance, security, and reliability. In Azure, Microsoft's cloud platform, you’ll use Azure Monitor to ensure your resources and applications run smoothly. 

Azure Monitor is a comprehensive monitoring service that helps you understand how your cloud environment performs and proactively identifies issues. 

Monitoring your Azure environment can help optimize resource usage and costs, ensure compliance, and resolve performance or security quickly.

In this tutorial, you’ll learn the basics of Azure Monitor, how to set it up, and how to use it to your advantage for performance monitoring, cost management, security, and compliance.

What is Azure Monitor?

Azure Monitor is used to collect data on your resources, and analyze and visualize that data to monitor performance and identify issues.  

The Azure Monitor overview screen

Azure Monitor

Azure Monitor has three core components: 

  • Application insights, used to monitor web applications.
  • Log analytics, used to query and analyze logged event data.
  • Alerts, used to set up automatic notifications and actions when issues are detected.

If you want to try out Azure Monitor, the easiest way to do so is to sign up for an Azure Free account or an Azure Student Account. This will give you 12 months of free access to popular services in Azure, including Monitor.

Once your free access is over, you’ll revert to the primary pricing model in Azure, pay-as-you-go. Pay-as-you-go is a consumption-based pricing model, meaning you’ll only pay for what you use. In addition, Azure provides monthly free amounts for some services.  

In Azure Monitor, for example, you don’t pay to use standard metrics collected from resources. If you create custom metrics, however, Azure will charge you based on the size of the ingested data. The most significant cost in Azure Monitor is typically for log data ingestion and retention. The more log data you ingest and the longer you keep that data, the higher the costs.  

Cost calculation in Azure can be quite complicated and depends on several factors, including the Azure Region you’re in. To calculate costs more in detail, it is best to use the pricing calculator

Setting Up Azure Monitor

Azure Monitor is available out of the box once you have an active subscription in Azure.

If you need to (re)create a subscription or want to add a new one, follow the steps outlined in this tutorial on setting up Azure.

To use all the features of Azure Monitor, you’ll also need one or more active resources to monitor, such as a virtual machine (VM) or a storage account.

Monitoring solutions for common scenarios

Azure Monitor offers additional support for some common monitoring scenarios.  

One common scenario is monitoring virtual machines. Azure provides monitoring support for VMs with VM Insights. VM Insights provides a set of predefined workbooks that allow you to quickly and easily set up monitoring for VMs, including setting up the Azure Monitor Agent to monitor the workloads and VM guest operating system. A workbook is used to create customizable and interactive reports and visualizations within Monitor. 

Another common monitoring scenario is using Azure Monitor for containerized applications. Azure Monitor provides features that allow you to collect and analyze data from Kubernetes clusters and also allows integration with Prometheus, a widely used open-source monitoring toolkit.

The final monitoring solution we’ll discuss here is  Application Insights. Application Insights used to be a separate service in Azure but is now integrated as part of Azure Monitor. Application Insights is specifically used to monitor web applications. These applications do not have to run in Azure. Application Insights is also able to monitor applications running on-premises or in other cloud environments. 

Data collection and analysis

Azure Monitor collects data from your resources. These data can either be metrics or logs. 

Metrics

Metrics are numeric data collected at regular intervals from resources, such as memory usage of a virtual machine. 

There are three main types of metrics in Azure: 

  • Standard or platform metrics: these are collected from Azure resources.
  • Custom metrics: these are metrics you define yourself and can also be collected externally.
  • Prometheus metrics: these are specifically collected from Kubernetes clusters and are handled using open-source analysis tools such as PromQL and Grafana.

You’ll explore these metrics in the Metrics Explorer. This feature of Azure Monitor allows you to create custom charts of metrics of interest quickly and easily. 

To create a standard metric chart, follow these steps: 

  1. Go to Monitor from the Azure Portal.
  2. Select Metrics on the left. 
  3. Choose the Scope of the chart; this is the resource or group of resources you want to monitor. 
  4. Choose the type of metric and the aggregation. 

An example of a metrics chart

Example of a metrics chart

You can further configure the charts by choosing the chart type, applying filters, or setting the time range. Additionally, you can customize the charts by setting up side-by-side comparisons of multiple resources or adding them to a dashboard for later use. 

Logs

Logs are event data related to automatic or use actions in Azure, such as modifications made to a virtual machine. In Log Analytics, you can query log data and analyze the results by creating tables or charts. 

To help you get started with this, Log Analytics has a set of predefined query scripts that allow you to query logs without having to write the queries yourself. 

You can access these predefined queries by following these steps: 

  1. Go to Monitor from the Azure Portal. 
  2. Select Log Analytics on the left. 
  3. The ‘Queries’ dialog will automatically appear. 
  4. Choose the category of your query from the list on the left. You can also use the search bar to find a specific query. 
  5. Click ‘Load to editor’ to load it in the editor, or click ‘Run’ to immediately run the query. 

The Queries tab with predefined queries in Logs

The Queries tab with predefined queries in Logs

If you want to customize the queries or write your own, you need to use the Kusto Query Language (KQL). This is a custom query language used in Azure, similar to SQL. 

Setting up alerts

With Alerts, you can set up automatic actions when Azure Monitor detects specific issues like low resource availability. You can set up the alert thresholds and logic, and make sure the right people are automatically notified when the alert triggers. 

It is even possible to set up automatic actions when an alert is triggered, like running a script or temporarily disabling a resource. 

There are three types of alerts you can create: 

  • Alert rule: An alert rule is used to define specific conditions that, when met, trigger an alert.
  • Alert processing rule: An alert processing rule is used to automate actions or modifications to alerts after they have been triggered.
  • Action group: An action group is a collection of notifications and action preferences that define how to respond when an alert rule is triggered.

Follow these steps to set up an example alert rule with notification: 

  1. Go to Monitor from the Azure Portal.
  2. Select ‘Alerts’ on the left.
  3. Click Create > Alert Rule.
  4. Choose the resource scope.
  5. Go to the tab ‘Conditions’ to create the alert logic. 
  6. Go to ‘Actions’ and fill in the details in the ‘Quick Actions’ tab on the right to set up a notification.
  7. Go to the tab ‘Details’ to fill in the alert name and choose its severity. 
  8. Finish the alert creation by clicking ‘Review+create.’

Creating an alert rule in Azure Monitor

Practical Use Cases and Examples

Performance monitoring

Suppose we would like to track and monitor KPIs for a web application. 

We could set up Azure Monitor using these steps:  

  1. Define KPIs. For example, request rate, response time, and error rate.
  2. Set up these KPIs in Application Insights so we can visualize and track them.
  3. Set up alerts for KPI thresholds. For example, trigger an alert if the average response time exceeds 5 seconds.

Cost management

The primary pricing model in Azure is the consumption-based ‘pay-as-you-go’ model. We can use Azure Monitor for cost-saving purposes by identifying underutilized resources. For example, the cost of VMs is determined by their memory and CPU usage. We could track this by following these steps: 

  1. Set up metrics to track memory and CPU usage of all VMs.
  2. Create a chart to track both metrics over a pre-defined period (e.g., the last 30 days).
  3. Identify VMs with consistent low memory or CPU usage.
  4. Optionally, we can set up an alert to alert us to low usage in the future.

Security and compliance

While Azure has other services available specifically for security or compliance, Azure Monitor can assist by analyzing, visualizing, or summarizing relevant log data. For example, we could use Azure Monitor to help with compliance and auditing. 

  1. Set up a Log Analytics workspace to collect security logs.
  2. Create a workbook for auditing logs.
  3. Create a custom compliance dashboard to track the compliance status of your resources.

Advanced Azure Monitor Features and Customization

Azure Monitor offers advanced features that allow integration with other Azure services or external sources. This allows for customization of monitoring solutions to meet specific needs.

Integrating with other Azure services

Azure can ingest log data from any other service in Azure. For example, we can send recommendations and alerts from the Azure Security Center to a log analytics workspace. We can then analyze and visualize the data to gain new insights, identify potential issues, and optimize the security of our cloud environment. 

Integrating with external sources

In some cases, you might want to send data from or to Azure Monitor from sources external to Azure. 

To send data to Azure Monitor, you can make use of its SDKs or APIs: 

  • Send custom metrics with the Azure Monitor SDK for your programming language (e.g., Python) or the REST API using REST requests. 
  • Send custom logs with the Logs Ingestion API to a Log Analytics workspace.

To send data from Azure Monitor, you can connect Azure Monitor to other Microsoft products like PowerBI and Excel. You can set up an automatic data flow and then use their features to analyze and visualize the data. This can come in handy if you want to create a more detailed or customized dashboard in PowerBI or if you have existing dashboards that need to use data from Azure. 

Best Practices for Azure Monitoring

Implementing best practices for Azure Monitoring ensures that you effectively manage and optimize your Azure environment. These practices help you set up robust monitoring strategies and continuously improve your monitoring setup.

Setting up effective monitoring strategies

Proactive monitoring helps identify potential issues before they become critical problems. Here are some effective monitoring strategies you can use: 

Strategy 1: Establish baseline metrics and thresholds

Start by defining baseline metrics that represent normal operating conditions for your resources. Use these baselines to set appropriate alert thresholds. This helps distinguish between normal variations and actual issues. 

For example, determine the average CPU usage for your VMs under normal load and set a threshold slightly above this average to detect potential performance issues.

Continuously analyze collected data to refine baselines and thresholds, ensuring they remain relevant as your environment evolves.

Strategy 2: Set up effective alert management

Effective alert management is crucial for maintaining a balance between being informed and avoiding unnecessary distractions. 

Too many alerts can overwhelm you, leading to essential alerts being missed. To avoid alert fatigue, you can group related alerts to reduce the number of notifications. You can also use temporary suppression conditions in your alert rules to avoid repeated alerts for known issues. 

It is also important to differentiate between critical and non-critical alerts as part of effective alert management. This allows critical alerts to be prioritized and ensures that high-priority issues receive immediate attention.

To help differentiate alerts, assign severity levels to them and configure notification channels accordingly. For instance, high-severity alerts can be sent via SMS and email, while low-severity alerts can be sent via less intrusive channels like dashboards or periodic reports.

Continuous improvement

Regularly reviewing and updating your monitoring setup is essential for keeping it effective and relevant. 

Here are some tips to ensure continuous improvement:  

  • Periodically review monitoring setups: Schedule regular reviews of your monitoring configurations to ensure they align with current operational requirements and business goals.
  • Audit your monitoring: Perform audits to identify gaps in monitoring coverage and to ensure compliance with internal and external standards.
  • Refine regularly: Adjust thresholds, update alert rules, and refine dashboards based on the latest data and performance trends.
  • Use feedback loops: Establish a feedback loop where incidents and alerts are analyzed post-resolution to improve monitoring rules and configurations.

Conclusion

Azure Monitor is an essential tool for maintaining the performance, security, and reliability of your Azure resources. By leveraging its comprehensive monitoring capabilities, you can proactively identify and resolve issues and optimize your cloud resources. 

If you’d like to master the basics of Azure, take a look at the Azure Fundamentals Track. This track will also prepare you for your first Azure certification

Azure Monitor FAQs

What is Azure Monitor used for?

Azure Monitor tracks resource performance and identifies and handles potential issues.

Can you monitor external resources with Azure Monitor?

Yes, you can connect Azure Monitor to resources on-premises or in other cloud environments.

Is it possible to use custom metrics in Azure Monitor?

Yes, you can create or import your own metrics into Azure Monitor and use them in your analysis.

Is Azure Monitor free to use?

Azure Monitor is part of the 12-month free services offer if you sign up for an Azure Free or Student Account.

Can Azure Monitor be used for real-time monitoring?

Yes, Azure Monitor can be used for both real-time monitoring and analyzing past data.


Photo of Anneleen Rummens
Author
Anneleen Rummens
LinkedIn
Twitter

Anneleen is a data scientist with a background in statistics and social sciences. She currently works as a freelance data scientist in finance and is studying a postgraduate degree in Applied AI. Anneleen is the instructor of four DataCamp courses including 'Azure Management and Governance'.

Topics

Top DataCamp Courses

Course

Introduction to Azure

3 hr
13.6K
Learn about the power of Microsoft Azure and cloud computing software to help you improve your data engineering skills.
See DetailsRight Arrow
Start Course
See MoreRight Arrow
Related

blog

8 of The Most Popular Machine Learning Tools

Explore the top 8 machine learning tools essential for modern ML practitioners. From Azure to Vertex AI, discover their key features and uses.
Kurtis Pykes 's photo

Kurtis Pykes

12 min

blog

A Comprehensive Guide to Using Azure Spot Instances for Cost Reduction

Explore how Azure Spot Virtual Machines work, how they can significantly reduce your cloud costs, and discover strategies for their practical implementation.
Anirudh Kulkarni's photo

Anirudh Kulkarni

10 min

cheat-sheet

Azure CLI Cheat sheet

With this Azure CLI cheat sheet, you'll have a handy reference guide to executing commands to create, manage, and deploy resources like virtual machines, databases, and storage accounts.
Richie Cotton's photo

Richie Cotton

9 min

tutorial

How to Set Up and Configure Azure: Beginner's Guide

Learn how to set up and configure Azure with this beginner's guide. Follow easy steps to navigate the Azure portal, create resources, and manage your cloud services.
Florin Angelescu's photo

Florin Angelescu

8 min

tutorial

A Beginner's Guide to Azure Machine Learning

Explore Azure Machine Learning in our beginner's guide to setting up, deploying models, and leveraging AutoML & ML Studio in the Azure ecosystem.
Moez Ali's photo

Moez Ali

11 min

tutorial

How to Set Up and Configure AWS: A Comprehensive Tutorial

Learn how to set up and configure your AWS account for the first time with this comprehensive tutorial. Discover essential settings, best practices for security, and how to leverage AWS services for data analysis and machine learning.
Joleen Bothma's photo

Joleen Bothma

30 min

See MoreSee More