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/metrics-custom-overview.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ author: EdB-MSFT
5
5
ms.service: azure-monitor
6
6
ms-author: edbaynash
7
7
ms.topic: conceptual
8
-
ms.date: 01/04/2024
8
+
ms.date: 01/07/2024
9
9
ms.reviewer: priyamishra
10
10
---
11
11
# Custom metrics in Azure Monitor (preview)
@@ -83,7 +83,7 @@ To understand the limit of 50,000 on time series, consider the following metric:
83
83
84
84
> *Server response time* with Dimensions: *Region*, *Department*, *CustomerID*
85
85
86
-
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.
86
+
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.
87
87
88
88
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.
89
89
@@ -98,7 +98,7 @@ Follow the steps below to see your current total active time series metrics, and
98
98
1. Select the **Apply** button.
99
99
1. Choose either **Active Time Series**, **Active Time Series Limit**, or **Throttled Time Series**.
100
100
101
-
There is 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.
101
+
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.
102
102
103
103
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.
Copy file name to clipboardExpand all lines: articles/azure-monitor/essentials/metrics-store-custom-rest-api.md
+54-98Lines changed: 54 additions & 98 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ author: EdB-MSFT
5
5
services: azure-monitor
6
6
ms.reviewer: priyamishra
7
7
ms.topic: how-to
8
-
ms.date: 10/18/2023
8
+
ms.date: 01/07/2024
9
9
ms.author: edbaynash
10
10
---
11
11
# Send custom metrics for an Azure resource to the Azure Monitor metrics store by using a REST API
@@ -15,8 +15,21 @@ This article shows you how to send custom metrics for Azure resources to the Azu
15
15
> [!NOTE]
16
16
> The REST API only permits sending custom metrics for Azure resources. To send metrics for resources in other environments or on-premises, use [Application Insights](../app/api-custom-events-metrics.md).
17
17
18
+
## Send REST requests to ingest custom metrics
19
+
18
20
When you send custom metrics to Azure Monitor, each data point, or value, reported in the metrics must include the following information.
19
21
22
+
+ Authentication token
23
+
+ Subject
24
+
+ Region
25
+
+ Timestamp
26
+
+ Namespace
27
+
+ Name
28
+
+ Dimension keys
29
+
+ Dimension values
30
+
+ Metric values
31
+
32
+
20
33
### Authentication
21
34
22
35
To submit custom metrics to Azure Monitor, the entity that submits the metric needs a valid Microsoft Entra token in the **Bearer** header of the request. Supported ways to acquire a valid bearer token include:
@@ -29,6 +42,36 @@ To submit custom metrics to Azure Monitor, the entity that submits the metric ne
29
42
> [!TIP]
30
43
> When you request a Microsoft Entra token to emit custom metrics, ensure that the audience or resource that the token is requested for is `https://monitoring.azure.com/`. Be sure to include the trailing slash.
31
44
45
+
### Get an authorization token
46
+
47
+
Once you have created your managed identity or service principal and assigned **Monitoring Metrics Publisher** permissions, you can get an authorization token by using the following request:
48
+
49
+
```console
50
+
curl -X POST 'https://login.microsoftonline.com/<tennant ID>/oauth2/token' \
Save the access token from the response for use in the following HTTP requests.
73
+
74
+
32
75
### Subject
33
76
34
77
The subject property captures which Azure resource ID the custom metric is reported for. This information is encoded in the URL of the API call. Each API can submit metric values for only a single Azure resource.
@@ -115,11 +158,13 @@ With this process, you can emit multiple values for the same metric/dimension co
115
158
116
159
### Sample custom metric publication
117
160
118
-
In the following example, you create a custom metric called **Memory Bytes in Use** under the metric namespace **Memory Profile** for a virtual machine. The metric has a single dimension called **Process**. For the timestamp, metric values are emitted for two processes.
161
+
In the following example, create a custom metric called **Memory Bytes in Use** under the metric namespace **Memory Profile** for a virtual machine. The metric has a single dimension called **Process**. For the timestamp, metric values are emitted for two processes.
162
+
163
+
Store the following JSON in a file called *custommetric.json* on your local computer. Update the time parameter so that it's within the last 20 minutes. You can't put a metric into the store that's more than 20 minutes old.
119
164
120
165
```json
121
166
{
122
-
"time": "2018-08-20T11:25:20-7:00",
167
+
"time": "2024-01-07T11:25:20-7:00",
123
168
"data": {
124
169
125
170
"baseData": {
@@ -154,88 +199,10 @@ In the following example, you create a custom metric called **Memory Bytes in Us
154
199
}
155
200
```
156
201
157
-
158
-
159
-
160
-
161
-
162
-
__________________
163
-
164
-
## Create and authorize a service principal to emit metrics
165
-
166
-
A service principal is an application whose tokens can be used to authenticate and grant access to specific Azure resources by using Microsoft Entra ID (formerly _Azure Active Directory_). Resources include user apps, services, or automation tools.
167
-
168
-
1.[Create a Microsoft Entra application and service principal](../../active-directory/develop/howto-create-service-principal-portal.md) that can access resources.
169
-
170
-
1. Save the tenant ID, new client ID, and client secret value for your app for use in token requests.
171
-
172
-
1. The app must be assigned the **Monitoring Metrics Publisher** role for the resources you want to emit metrics against. If you plan to use the app to emit custom metrics against many resources, you can assign the role at the resource group or subscription level. For more information, see [Assign Azure roles by using the Azure portal](../../role-based-access-control/role-assignments-portal.md).
173
-
174
-
## Get an authorization token
175
-
176
-
Send the following request in the command prompt or by using a client like Postman.
177
-
178
-
```console
179
-
curl -X POST 'https://login.microsoftonline.com/<tennant ID>/oauth2/token' \
Save the access token from the response for use in the following HTTP requests.
202
-
203
-
## Send a metric via the REST API
204
-
205
-
1. Paste the following JSON into a file. Save it as *custommetric.json* on your local computer. Update the time parameter so that it's within the last 20 minutes. You can't put a metric into the store that's more than 20 minutes old. The metrics store is optimized for alerting and real-time charting.
206
-
207
-
```JSON
208
-
{
209
-
"time": "2023-01-03T11:00:20",
210
-
"data": {
211
-
"baseData": {
212
-
"metric": "QueueDepth",
213
-
"namespace": "QueueProcessing",
214
-
"dimNames": [
215
-
"QueueName",
216
-
"MessageType"
217
-
],
218
-
"series": [
219
-
{
220
-
"dimValues": [
221
-
"ImagesToProcess",
222
-
"JPEG"
223
-
],
224
-
"min": 3,
225
-
"max": 20,
226
-
"sum": 28,
227
-
"count": 3
228
-
}
229
-
]
230
-
}
231
-
}
232
-
}
233
-
```
234
-
235
-
1. Submit the following HTTP POST request by using the following variables:
236
-
- **location**: Deployment region of the resource you're emitting metrics for.
237
-
- **resourceId**: Resource ID of the Azure resource you're tracking the metric against.
238
-
- **accessToken**: The authorization token acquired from the previous step.
202
+
Submit the following HTTP POST request by using the following variables:
203
+
+`location`: Deployment region of the resource you're emitting metrics for.
204
+
+`resourceId`: Resource ID of the Azure resource you're tracking the metric against.
205
+
+`accessToken`: The authorization token acquired from the *Get an authorization token* step.
239
206
240
207
```console
241
208
curl -X POST 'https://<location>/.monitoring.azure.com<resourceId>/metrics' \
@@ -244,17 +211,6 @@ Save the access token from the response for use in the following HTTP requests.
244
211
-d @custommetric.json
245
212
```
246
213
247
-
1. Change the timestamp and values in the JSON file. The 'time' value in the JSON file is expected to be in UTC.
248
-
249
-
1. Repeat the previous two steps a few times to create data for several minutes.
250
-
251
-
## Troubleshooting
252
-
253
-
If you receive an error message with some part of the process, consider the following troubleshooting information:
254
-
255
-
- If you can't issue metrics against a subscription or resource group, or resource, check that your application or service principal has the **Monitoring Metrics Publisher** role assigned in **Access control (IAM)**.
256
-
- Check that the number of dimension names matches the number of values.
257
-
- Check that you aren't emitting metrics against a region that doesn't support custom metrics. For more information, see [supported regions](./metrics-custom-overview.md#supported-regions).
258
214
259
215
## View your metrics
260
216
@@ -270,9 +226,9 @@ If you receive an error message with some part of the process, consider the foll
270
226
271
227
1. In the **Scope** dropdown list, select the resource you send the metric for.
272
228
273
-
1. In the **Metric Namespace** dropdown list, select **queueprocessing**.
229
+
1. In the **Metric Namespace** dropdown list, select **Memory Profile**.
274
230
275
-
1. In the **Metric** dropdown list, select **QueueDepth**.
231
+
1. In the **Metric** dropdown list, select **Memory Bytes in Use**.
0 commit comments