You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-monitor/essentials/data-platform-metrics.md
+5-2Lines changed: 5 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: Learn about metrics in Azure Monitor, which are lightweight monitor
4
4
author: bwren
5
5
ms.reviewer: priyamishra
6
6
ms.topic: conceptual
7
-
ms.date: 04/25/2023
7
+
ms.date: 03/10/2024
8
8
ms.author: bwren
9
9
---
10
10
@@ -46,12 +46,15 @@ The differences between each of the metrics are summarized in the following tabl
46
46
47
47
Azure Monitor collects metrics from the following sources. After these metrics are collected in the Azure Monitor metric database, they can be evaluated together regardless of their source:
48
48
49
-
-**Azure resources**: Platform metrics are created by Azure resources and give you visibility into their health and performance. Each type of resource creates a [distinct set of metrics](./metrics-supported.md) without any configuration required. Platform metrics are collected from Azure resources at one-minute frequency unless specified otherwise in the metric's definition.
49
+
-**Azure resources**: Platform metrics are created by Azure resources and give you visibility into their health and performance. Each type of resource creates a [distinct set of metrics](./metrics-supported.md) without any configuration required. Platform metrics are collected from Azure resources at one-minute frequency unless specified otherwise in the metric's definition.
50
50
-**Applications**: Application Insights creates metrics for your monitored applications to help you detect performance issues and track trends in how your application is being used. Values include _Server response time_ and _Browser exceptions_.
51
51
-**Virtual machine agents**: Metrics are collected from the guest operating system of a virtual machine. You can enable guest OS metrics for Windows virtual machines by using the [Azure Monitor Agent](/azure/azure-monitor/agents/agents-overview). Azure Monitor Agent replaces the legacy agents - [Windows diagnostic extension](../agents/diagnostics-extension-overview.md) and the [InfluxData Telegraf agent](https://www.influxdata.com/time-series-platform/telegraf/) for Linux virtual machines.
52
52
-**Custom metrics**: You can define metrics in addition to the standard metrics that are automatically available. You can [define custom metrics in your application](../app/api-custom-events-metrics.md) that's monitored by Application Insights. You can also create custom metrics for an Azure service by using the [custom metrics API](./metrics-store-custom-rest-api.md).
53
53
-**Kubernetes clusters**: Kubernetes clusters typically send metric data to a local Prometheus server that you must maintain. [Azure Monitor managed service for Prometheus ](prometheus-metrics-overview.md) provides a managed service that collects metrics from Kubernetes clusters and store them in Azure Monitor Metrics.
54
54
55
+
> [!NOTE]
56
+
> Metrics collected from different sources and by different methods may be aggregated differently. For example, platform metrics are pre-aggregated and stored in a time-series database, while Prometheus metrics are stored as raw data.Resource metrics may also have a different latency than other metrics. This can lead to differences in metric values for a specific sample time. Over time when latency ceases to be an issue, and when analyzing the metrics at the same time granularity, these differences disappear.
57
+
55
58
## REST API
56
59
57
60
Azure Monitor provides REST APIs that allow you to get data in and out of Azure Monitor Metrics.
Copy file name to clipboardExpand all lines: articles/azure-monitor/essentials/migrate-to-batch-api.md
+24-19Lines changed: 24 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,17 +4,18 @@ description: How to migrate from the metrics API to the getBatch API
4
4
author: EdB-MSFT
5
5
services: azure-monitor
6
6
ms.topic: how-to
7
-
ms.date: 05/07/2023
7
+
ms.date: 03/11/2024
8
8
ms.author: edbaynash
9
+
ms.reviewer: priyamishra
9
10
10
11
# Customer intent: As a customer, I want to understand how to migrate from the metrics API to the getBatch API
11
12
---
12
13
# How to migrate from the metrics API to the getBatch API
13
14
14
-
Heavy use of the [metrics API](/rest/api/monitor/metrics/list?tabs=HTTP) can result in throttling or performance problems. Migrating to the [metrics:getBatch](/rest/api/monitor/metrics-batch/batch?tabs=HTTP) API allows you to query multiple resources in a single REST request. The two APIs share a common set of query parameter and response formats that make migration easy.
15
+
Heavy use of the [metrics API](/rest/api/monitor/metrics/list?tabs=HTTP) can result in throttling or performance problems. Migrating to the [`metrics:getBatch`](/rest/api/monitor/metrics-batch/batch?tabs=HTTP) API allows you to query multiple resources in a single REST request. The two APIs share a common set of query parameter and response formats that make migration easy.
15
16
16
17
## Request format
17
-
The metrics:getBatch API request has the following format:
18
+
The `metrics:getBatch` API request has the following format:
18
19
```http
19
20
POST /subscriptions/<subscriptionId>/metrics:getBatch?metricNamespace=<resource type namespace>&api-version=2023-10-01
Consider the following restrictions on which resources can be batched together when deciding if the metrics:getBatch API is the correct choice for your scenario.
45
+
Consider the following restrictions on which resources can be batched together when deciding if the `metrics:getBatch` API is the correct choice for your scenario.
45
46
46
47
- All resources in a batch must be in the same subscription.
47
48
- All resources in a batch must be in the same Azure region.
@@ -69,16 +70,16 @@ GET https://management.azure.com/subscriptions/12345678-1234-1234-1234-123456789
69
70
Replace `management.azure.com` with a regional endpoint for the Azure Monitor Metrics data plane using the following format: `<region>.metrics.monitor.azure.com` where `region` is region of the resources you're requesting metrics for. For the example, if the resources are in westus2, the hostname is `westus2.metrics.monitor.azure.com`.
70
71
71
72
1. Change the API name and path.
72
-
The metrics:getBatch API is a subscription level POST API. The resources for which the metrics are requested, are specified in the request body rather than in the URL path.
73
+
The `metrics:getBatch` API is a subscription level POST API. The resources for which the metrics are requested, are specified in the request body rather than in the URL path.
73
74
Change the url path as follows:
74
75
from `/subscriptions/12345678-1234-1234-1234-123456789abc/resourceGroups/sample-test/providers/Microsoft.Storage/storageAccounts/testaccount/providers/microsoft.Insights/metrics`
75
76
to `/subscriptions/12345678-1234-1234-1234-123456789abc/metrics:getBatch`
76
77
77
-
1. The `metricNamespace` query param is required for metrics:getBatch. For Azure standard metrics, the namespace name is usually the resource type of the resources you've specified. To check the namespace value to use, see the [metrics namespaces API](/rest/api/monitor/metric-namespaces/list?tabs=HTTP)
78
+
1. The `metricNamespace` query param is required for metrics:getBatch. For Azure standard metrics, the namespace name is usually the resource type of the resources you specified. To check the namespace value to use, see the [metrics namespaces API](/rest/api/monitor/metric-namespaces/list?tabs=HTTP)
78
79
1. Switch from using the `timespan` query param to using `starttime` and `endtime`. For example, `?timespan=2023-04-20T12:00:00.000Z/2023-04-22T12:00:00.000Z` becomes `?startime=2023-04-20T12:00:00.000Z&endtime=2023-04-22T12:00:00.000Z`.
79
80
1. Update the api-version query parameter as follows: `&api-version=2023-10-01`
80
-
1. The filter query param isn't prefixed with a `$` in the metrics:getBatch API. Change the query param from `$filter=` to `filter=`.
81
-
1. The metrics:getBatch API is a POST call with a body that contains a comma-separated list of resourceIds in the following format:
81
+
1. The filter query param isn't prefixed with a `$` in the `metrics:getBatch` API. Change the query param from `$filter=` to `filter=`.
82
+
1. The `metrics:getBatch` API is a POST call with a body that contains a comma-separated list of resourceIds in the following format:
82
83
For example:
83
84
```json
84
85
{
@@ -123,7 +124,7 @@ The following example shows the converted batch request.
123
124
124
125
## Response Format
125
126
126
-
The response format of the metrics:getBatch API encapsulates a list of individual metrics call responses in the following format:
127
+
The response format of the `metrics:getBatch` API encapsulates a list of individual metrics call responses in the following format:
127
128
128
129
```json
129
130
{
@@ -133,7 +134,7 @@ The response format of the metrics:getBatch API encapsulates a list of individua
133
134
}
134
135
```
135
136
136
-
A `resourceid` property has been added to each resources' metrics list in the metrics:getBatch API response.
137
+
A `resourceid` property was added to each resources' metrics list in the `metrics:getBatch` API response.
137
138
138
139
The following show sample response formats.
139
140
@@ -587,7 +588,7 @@ A `resourceid` property has been added to each resources' metrics list in the me
587
588
588
589
## Error response changes
589
590
590
-
In the metrics:getBatch error response, the error content is wrapped inside a top level "error" property on the response. For example,
591
+
In the `metrics:getBatch` error response, the error content is wrapped inside a top level "error" property on the response. For example,
591
592
592
593
+ Metrics API error response
593
594
@@ -611,26 +612,30 @@ In the metrics:getBatch error response, the error content is wrapped inside a to
611
612
612
613
## Troubleshooting
613
614
614
-
+ No returned data can be due to the wrong region being specified.
615
-
The batch API verifies that all of the resource IDs specified belong to the same subscriptionId and resource type. The batch API doesn't verify that all of the specified resource IDs are in the same region specified in the hostname. The only indicator that the region may be wrong for a given resource is getting empty time series data for all that resource.
616
-
for example,`"timeseries": [],`
617
-
615
+
+ Empty time series returned `"timeseries": []`
616
+
- An empty time series is returned when no data is available for the specified time range and filter. The most common cause is specifying a time range that doesn't contain any data. For example, if the time range is set to a future date.
617
+
- Another common cause is specifying a filter that doesn't match any resources. For example, if the filter specifies a dimension value that doesn't exist on any resources in the subscription and region combination, `"timeseries": []` is returned.
618
+
619
+
+ Wildcard filters
620
+
Using a wildcard filter such as `Microsoft.ResourceId eq '*'` causes the API to return a time series for every resourceId in the subscription and region. If the subscription and region combination contains no resources, an empty time series is returned. The same query without the wildcard filter would return a single time series, aggregating the requested metric over the requested dimensions, for example subscription and region. If there are no resources in the subscription and region combination, the API returns a single time series with a single data point of `0`.
621
+
622
+
618
623
+ Custom metrics aren't currently supported.
619
-
The metrics:getBatch API doesn't support querying custom metrics, or queries where the metric namespace name isn't a resource type. This is the case for VM Guest OS metrics that use the namespace "azure.vm.windows.guestmetrics" or "azure.vm.linux.guestmetrics".
624
+
The `metrics:getBatch` API doesn't support querying custom metrics, or queries where the metric namespace name isn't a resource type. This is the case for VM Guest OS metrics that use the namespace "azure.vm.windows.guestmetrics" or "azure.vm.linux.guestmetrics".
620
625
621
626
+ The top parameter applies per resource ID specified.
622
627
How the top parameter works in the context of the batch API can be a little confusing. Rather than enforcing a limit on the total time series returned by the entire call, it rather enforces the total time series returned *per metric per resource ID*. If you have a batch query with many '*' filters specified, two metrics, and four resource IDs with a top of 5. The maximum possible time series returned by that query is 40, that is 2x4x5 time series.
623
628
624
629
### 401 authorization errors
625
630
626
-
The individual metrics API requires a user have the [Monitoring Reader](/azure/role-based-access-control/built-in-roles#monitoring-reader) permission on the resource being queried. Because the metrics:getBatch API is a subscription level API, users must have the Monitoring Reader permission for the queried subscription to use the batch API. Even if users have Monitoring Reader on all the resources being queried in the batch API, the request fails if the user doesn't have Monitoring Reader on the subscription itself.
631
+
The individual metrics API requires a user have the [Monitoring Reader](/azure/role-based-access-control/built-in-roles#monitoring-reader) permission on the resource being queried. Because the `metrics:getBatch` API is a subscription level API, users must have the Monitoring Reader permission for the queried subscription to use the batch API. Even if users have Monitoring Reader on all the resources being queried in the batch API, the request fails if the user doesn't have Monitoring Reader on the subscription itself.
627
632
628
633
### 529 throttling errors
629
634
630
635
While the data plane batch API is designed to help mitigate throttling problems, 529 error codes can still occur which indicates that the metrics backend is currently throttling some customers. The recommended action is to implement an exponential backoff retry scheme.
631
636
632
637
## Paging
633
-
Paging is not supported by the metrics:getBatch API. The most common use-case for this API is frequently calling every few minutes for the same metrics and resources for the latest timeframe. Low latency is an important consideration so many customers parallelize their queries as much as possible. Paging forces customers into a sequential calling pattern that introduces additional query latency. In scenarios where requests return volumes of metric data where paging would be beneficial, it's recommended to split the query into multiple parallel queries.
638
+
Paging isn't supported by the metrics:getBatch API. The most common use-case for this API is frequently calling every few minutes for the same metrics and resources for the latest timeframe. Low latency is an important consideration so many customers parallelize their queries as much as possible. Paging forces customers into a sequential calling pattern that introduces additional query latency. In scenarios where requests return volumes of metric data where paging would be beneficial, it's recommended to split the query into multiple parallel queries.
634
639
635
640
## Billing
636
-
Yes all metrics data plane and batching calls are billed. For more information, see the **Azure Monitor native metrics** section in [Basic Log Search Queries](https://azure.microsoft.com/pricing/details/monitor/#pricing)
641
+
Yes all metrics data plane and batching calls are billed. For more information, see the **Azure Monitor native metrics** section in [Basic Log Search Queries](https://azure.microsoft.com/pricing/details/monitor/#pricing).
title: Retrieve activity log data using Azure monitor REST API
3
+
description: How to retrieve activity log data using Azure monitor REST API.
4
+
author: EdB-MSFT
5
+
ms.topic: conceptual
6
+
ms.date: 03/10/2024
7
+
ms.reviewer: priyamishra
8
+
9
+
# customer intent: As a developer, I want to learn how to retrieve activity log data using Azure monitor REST API.
10
+
---
11
+
12
+
# Retrieve activity log data using Azure monitor REST API
13
+
14
+
The Azure Activity Log is a log that provides insight into operations performed on resources in your subscription. Operations include create, update, delete, and other actions taken on resources. The Activity Log is a platform-wide log and isn't limited to a particular service. This article explains how to retrieve activity log data using the Azure Monitor REST API. For more information about the activity log, see [Azure Activity Log event schema](/azure/azure-monitor/essentials/activity-log-schema).
15
+
16
+
17
+
## Authentication
18
+
19
+
To retrieve resource logs, you must authenticate with Microsoft Entra. For more information, see [Azure monitoring REST API walkthrough](/azure/azure-monitor/essentials/rest-api-walkthrough?tabs=powershell#authenticate-azure-monitor-requests).
20
+
21
+
## Retrieve activity log data
22
+
23
+
Use the Azure Monitor REST API to query [activity log](/rest/api/monitor/activitylogs) data.
24
+
25
+
The following request format is used to request activity log data.
26
+
27
+
```curl
28
+
GET /subscriptions/<subscriptionId>/providers/Microsoft.Insights/eventtypes/management/values \
29
+
?api-version=2015-04-01 \
30
+
&$filter=<filter> \
31
+
&$select=<select>
32
+
host: management.azure.com
33
+
authorization: Bearer <token>
34
+
```
35
+
36
+
### $filter
37
+
`$filter` reduces the set of data collected. This argument is required and it also requires at least the start date/time.
38
+
The `$filter` argument accepts the following patterns:
39
+
- List events for a resource group: `$filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceGroupName eq <resourceGroupName>`.
40
+
- List events for a specific resource: `$filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceUri eq <resourceURI>`.
41
+
- List events for a subscription in a time range: `$filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z'`.
42
+
- List events for a resource provider: `$filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceProvider eq <resourceProviderName>`.
43
+
- List events for a correlation ID:` $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and correlationId eq '<correlationID>`.
44
+
45
+
46
+
### $select
47
+
`$select` fetches a specified list of properties for the returned events.
48
+
The `$select` argument is a comma separated list of property names to be returned.
The following sample requests use the Azure Monitor REST API to query an activity log.
53
+
### Get activity logs with filter:
54
+
55
+
The following example gets the activity logs for resource group `MSSupportGroup` between the dates `2023-03-21T20:00:00Z` and `2023-03-24T20:00:00Z`
56
+
57
+
```HTTP
58
+
GET https://management.azure.com/subscriptions/12345678-abcd-98765432-abcdef012345/providers/microsoft.insights/eventtypes/management/values?api-version=2015-04-01&$filter=eventTimestamp ge '2023-03-21T20:00:00Z' and eventTimestamp le '2023-03-24T20:00:00Z' and resourceGroupName eq 'MSSupportGroup'
59
+
```
60
+
### Get activity logs with filter and select:
61
+
62
+
The following example gets the activity logs for resource group `MSSupportGroup`, between the dates `2023-03-21T20:00:00Z` and `2023-03-24T20:00:00Z`, returning the elements eventName, operationName, status, eventTimestamp, correlationId, submissionTimestamp, and level.
63
+
64
+
```HTTP
65
+
GET https://management.azure.com/subscriptions/12345678-abcd-98765432-abcdef012345/providers/microsoft.insights/eventtypes/management/values?api-version=2015-04-01&$filter=eventTimestamp ge '2023-03-21T20:00:00Z' and eventTimestamp le '2023-03-24T20:00:00Z'and resourceGroupName eq 'MSSupportGroup'&$select=eventName,operationName,status,eventTimestamp,correlationId,submissionTimestamp,level
0 commit comments