Custom metrics in Azure Monitor (preview) - Azure Monitor (2024)

  • Article

Azure makes some metrics available to you out of the box. These metrics are called standard or platform. Custom metrics are performance indicators or business-specific metrics that can be collected via your application's telemetry, the Azure Monitor Agent, a diagnostics extension that runs on your Azure resources, or an external monitoring system. Once custom metrics are published to Azure Monitor, you can browse, query, and alert on them along side the standard Azure metrics.

Azure Monitor custom metrics are currently in public preview.

Methods to send custom metrics

Custom metrics can be sent to Azure Monitor via several methods:

  • Use Azure Application Insights SDK to instrument your application by sending custom telemetry to Azure Monitor.
  • Install the Azure Monitor Agent on your Windows or Linux Azure virtual machine or virtual machine scale set and use a data collection rule to send performance counters to Azure Monitor metrics.
  • Install the Azure Diagnostics extension on your Azure VM, Virtual Machine Scale Set, classic VM, or classic cloud service. Then send performance counters to Azure Monitor.
  • Install the InfluxData Telegraf agent on your Azure Linux VM. Send metrics by using the Azure Monitor output plug-in.
  • Send custom metrics directly to the Azure Monitor REST API.

Pricing model and retention

In general, there's no cost to ingest standard metrics (platform metrics) into an Azure Monitor metrics store, but custom metrics incur costs when they enter general availability. Queries to the metrics API do incur costs. For details on when billing is enabled for custom metrics and metrics queries, check the Azure Monitor pricing page.

Custom metrics are retained for the same amount of time as platform metrics.

Note

Metrics sent to Azure Monitor via the Application Insights SDK are billed as ingested log data. They incur additional metrics charges only if the Application Insights feature Enable alerting on custom metric dimensions has been selected. This checkbox sends data to the Azure Monitor metrics database by using the custom metrics API to allow the more complex alerting. Learn more about the Application Insights pricing model and prices in your region.

Custom metric definitions

Each metric data point published contains a namespace, name, and dimension information. The first time a custom metric is emitted to Azure Monitor, a metric definition is automatically created. This new metric definition is then discoverable on any resource that the metric is emitted from via the metric definitions. There's no need to predefine a custom metric in Azure Monitor before it's emitted.

Note

Application Insights, the diagnostics extension, and the InfluxData Telegraf agent are already configured to emit metric values against the correct regional endpoint and carry all the preceding properties in each emission.

Using custom metrics

After custom metrics are submitted to Azure Monitor, you can browse through them via the Azure portal and query them via the Azure Monitor REST APIs. You can also create alerts on them to notify you when certain conditions are met.

Note

You need to have a reader or contributor role to view custom metrics. See Monitoring Reader.

Browse your custom metrics via the Azure portal

  1. Go to the Azure portal.
  2. Select the Monitor pane.
  3. Select Metrics.
  4. Select a resource that you've emitted custom metrics against.
  5. Select the metrics namespace for your custom metric.
  6. Select the custom metric.

For more information on viewing metrics in the Azure portal, see Analyze metrics with Azure Monitor metrics explorer.

Latency and storage retention

A newly added metric or a newly added dimension to a metric might take up to 3 minutes to appear. After the data is in the system, it should appear in less than 30 seconds 99 percent of the time.

If you delete a metric or remove a dimension, the change can take a week to a month to be deleted from the system.

Quotas and limits

Azure Monitor imposes the following usage limits on custom metrics:

CategoryLimit
Total active time series in a subscription per region50,000
Dimension keys per metric10
String length for metric namespaces, metric names, dimension keys, and dimension values256 characters
The combined length of all custom metric names, using utf-8 encoding64 KB

An active time series is defined as any unique combination of metric, dimension key, or dimension value that has had metric values published in the past 12 hours.

To understand the limit of 50,000 on time series, consider the following metric:

Server response time with Dimensions: Region, Department, CustomerID

With this metric, if you have 10 regions, 20 departments, and 100 customers that gives you 10 x 20 x 100 = 20,000 time series.

If you have 100 regions, 200 departments, and 2,000 customers, that gives you 100 x 200 x 2,000 = 40 million time series, which is far over the limit just for this metric alone.

Again, this limit isn't for an individual metric. It's for the sum of all such metrics across a subscription and region.

Follow the steps below to see your current total active time series metrics, and more information to assist with troubleshooting.

  1. Navigate to the Monitor section of the Azure portal.
  2. Select Metrics on the left hand side.
  3. Under Select a scope, check the applicable subscription and resource groups.
  4. Under Refine scope, choose Custom Metric Usage and the desired location.
  5. Select the Apply button.
  6. Choose either Active Time Series, Active Time Series Limit, or Throttled Time Series.

There's a limit of 64 KB on the combined length of all custom metrics names, assuming utf-8 or 1 byte per character. If the 64-KB limit is exceeded, metadata for additional metrics won't be available. The metric names for additional custom metrics won't appear in the Azure portal in selection fields, and won't be returned by the API in requests for metric definitions. The metric data is still available and can be queried.

When the limit has been exceeded, reduce the number of metrics you're sending or shorten the length of their names. It then takes up to two days for the new metrics' names to appear.

To avoid reaching the limit, don't include variable or dimensional aspects in your metric names.For example, the metrics for server CPU usage,CPU_server_12345678-319d-4a50-b27e-1234567890ab and CPU_server_abcdef01-319d-4a50-b27e-abcdef012345 should be defined as metric CPU and with a Server dimension.

Design limitations and considerations

Using Application Insights for the purpose of auditing. The Application Insights telemetry pipeline is optimized for minimizing the performance impact and limiting the network traffic from monitoring your application. As such, it throttles or samples (takes only a percentage of your telemetry and ignores the rest) if the initial dataset becomes too large. Because of this behavior, you can't use it for auditing purposes because some records are likely to be dropped.

Metrics with a variable in the name. Don't use a variable as part of the metric name. Use a constant instead. Each time the variable changes its value, Azure Monitor generates a new metric. Azure Monitor then quickly hits the limit on the number of metrics. Generally, when developers want to include a variable in the metric name, they really want to track multiple time series within one metric and should use dimensions instead of variable metric names.

High-cardinality metric dimensions. Metrics with too many valid values in a dimension (a high cardinality) are much more likely to hit the 50,000 limit. In general, you should never use a constantly changing value in a dimension. Timestamp, for example, should never be a dimension. You can use server, customer, or product ID, but only if you have a smaller number of each of those types.

As a test, ask yourself if you would ever chart such data on a graph. If you have 10 or maybe even 100 servers, it might be useful to see them all on a graph for comparison. But if you have 1,000, the resulting graph would likely be difficult or impossible to read. A best practice is to keep it to fewer than 100 valid values. Up to 300 is a gray area. If you need to go over this amount, use Azure Monitor custom logs instead.

If you have a variable in the name or a high-cardinality dimension, the following issues can occur:

  • Metrics become unreliable because of throttling.
  • Metrics Explorer won't work.
  • Alerting and notifications become unpredictable.
  • Costs can increase unexpectedly. Microsoft isn't charging for custom metrics with dimensions while this feature is in public preview. After charges start in the future, you'll incur unexpected charges. The plan is to charge for metrics consumption based on the number of time series monitored and number of API calls made.

If the metric name or dimension value is populated with an identifier or high-cardinality dimension by mistake, you can easily fix it by removing the variable part.

But if high cardinality is essential for your scenario, the aggregated metrics are probably not the right choice. Switch to using custom logs (that is, trackMetric API calls with trackEvent). However, consider that logs don't aggregate values, so every single entry will be stored. As a result, if you have a large volume of logs in a small time period (1 million a second, for example), it can cause throttling and ingestion delays.

Next steps

Use custom metrics from various services:

  • Send custom metrics to the Azure Monitor using the REST API
  • Virtual machine
  • Virtual Machine Scale Set
  • Azure virtual machine (classic)
  • Linux virtual machine using the Telegraf agent\
  • Classic cloud service
Custom metrics in Azure Monitor (preview) - Azure Monitor (2024)

FAQs

What are the limitations of Azure Monitor? ›

Alert and recording rules
LimitValue
Rule groups per Azure Monitor workspace, in an Azure subscription500 You can request an increase.
Rules per rule group20 This limit can't be increased.
Rule group evaluation intervalBetween 1 minute - 24 hours. Default is 1 minute.
Active alertsNo limit at this time.
Oct 10, 2023

What are custom metrics in Azure? ›

Custom metrics are performance indicators or business-specific metrics that can be collected via your application's telemetry, the Azure Monitor Agent, a diagnostics extension that runs on your Azure resources, or an external monitoring system.

How is monitoring VM metrics accomplished in Azure Monitor? ›

Metrics for the guest OS that runs in a VM must be collected through one or more agents, such as the Azure Monitor agent, that run on or as part of the guest OS. Guest OS metrics include performance counters that track guest CPU percentage or memory usage, both of which are frequently used for autoscaling or alerting.

What is the difference between Azure metrics and Azure Monitor? ›

Azure Monitor Metrics can only store numeric data in a particular structure, whereas Azure Monitor Logs can store a variety of data types that have their own structures. You can also perform complex analysis on Azure Monitor Logs data by using log queries, which can't be used for analysis of Azure Monitor Metrics data.

Is Azure monitor Agent in Preview? ›

The Azure Monitor Agent is the new, consolidated telemetry agent for collecting data from IaaS resources like virtual machines. By using the upload capability in this preview, you can upload the logs you send to Log Analytics workspaces to Event Hubs and Storage.

Why use custom metrics? ›

Custom metrics help you track your application KPIs: number of visitors, average customer basket size, request latency, or performance distribution for a custom algorithm. A custom metric is identified by a unique combination of a metric's name and tag values (including the host tag).

How do you use custom metrics? ›

Set up custom metrics
  1. Sign in to Google Analytics.
  2. Click Admin, and navigate to the property to which you want to add custom metrics.
  3. In the PROPERTY column, click Custom Definitions > Custom Metrics.
  4. Click the New Custom Metric button.
  5. Add a Name. ...
  6. From the Formatting Type dropdown, select an Integer, Currency, or Time.

What are metrics in an Azure monitor? ›

Azure Monitor Metrics is a feature of Azure Monitor that collects numeric data from monitored resources into a time-series database. Metrics are numerical values that are collected at regular intervals and describe some aspect of a system at a particular time.

What two types of data are used by Azure Monitor? ›

Application data
Data typeDescription
MetricsNumeric data measuring the performance of your application and user requests measured over intervals of time.
TracesTraces are a series of related events tracking end-to-end requests through the components of your application.
1 more row
Apr 8, 2024

Where does Azure Monitor get its data? ›

Azure Monitor collects and aggregates the data from every layer and component of your system across multiple Azure and non-Azure subscriptions and tenants. It stores it in a common data platform for consumption by a common set of tools that can correlate, analyze, visualize, and/or respond to the data.

What is the benefit of Azure Monitor? ›

Benefits of Azure Monitor

Visualizations, including charts and graphs for insights into resource performance. Application Insights, built-in metrics for understanding resource use, including inbound and outbound data, state, and application performance. Easy-to-create alerts.

Does Azure Monitor use log Analytics? ›

Log Analytics is a tool in the Azure portal to edit and run log queries from data collected by Azure Monitor logs and interactively analyze their results. You can use Log Analytics queries to retrieve records that match particular criteria, identify trends, analyze patterns, and provide various insights into your data.

Where are Azure Monitor metrics stored? ›

Data storage

For Azure Monitor: Metrics data is stored in the Azure Monitor metrics database. Log data is stored in the Azure Monitor logs store. Log Analytics is a tool in the Azure portal that can query this store.

What is the difference between count and sum in Azure Monitor? ›

Sum – the sum of all values captured over the aggregation interval. Sometimes referred to as the Total aggregation. Count – the number of measurements captured over the aggregation interval. Count doesn't look at the value of the measurement, only the number of records.

What are the limitations of Azure? ›

API Center limits
ResourceFree planStandard plan1
Maximum number of workspaces1 (Default)1 (Default)
Maximum number of custom metadata properties per entity31020
Maximum number of child properties in custom metadata property of type "object"1010
Maximum requests per minute (data plane)3,0006,000
5 more rows
Apr 8, 2024

What are the limitations of Azure functions? ›

Azure Functions has a maximum size of 1 gigabyte for deployment packages. The default execution time limit for the consumption-based pricing plan is five minutes, although users can increase this to 10 minutes. In the Premium and App Service plans, the minimum execution time is 30 minutes, and the maximum is unlimited.

What is the limitation of Azure virtual network? ›

Load balancer limits
ResourceDefault limitMaximum limit
Virtual networks100100
Local network sites2050
DNS servers per virtual network2020
Private IP addresses per virtual network4,0964,096
10 more rows

Top Articles
Latest Posts
Article information

Author: Sen. Emmett Berge

Last Updated:

Views: 6463

Rating: 5 / 5 (80 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Sen. Emmett Berge

Birthday: 1993-06-17

Address: 787 Elvis Divide, Port Brice, OH 24507-6802

Phone: +9779049645255

Job: Senior Healthcare Specialist

Hobby: Cycling, Model building, Kitesurfing, Origami, Lapidary, Dance, Basketball

Introduction: My name is Sen. Emmett Berge, I am a funny, vast, charming, courageous, enthusiastic, jolly, famous person who loves writing and wants to share my knowledge and understanding with you.