Skip to content

Commit 9c936c3

Browse files
committed
final
1 parent cf03c64 commit 9c936c3

File tree

1 file changed

+28
-27
lines changed

1 file changed

+28
-27
lines changed

articles/azure-monitor/essentials/prometheus-api-promql.md

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -115,32 +115,33 @@ Examples:
115115
POST https://k8s-02-workspace-abcd.eastus.prometheus.monitor.azure.com/api/v1/query
116116
--header 'Authorization: Bearer <access token>'
117117
--header 'Content-Type: application/x-www-form-urlencoded'
118-
--data-urlencode 'query=sum(
119-
container_memory_working_set_bytes
120-
* on(namespace,pod)
121-
group_left(workload, workload_type) namespace_workload_pod:kube_pod_owner:relabel{ workload_type="deployment"}) by (pod)'
118+
--data-urlencode 'query=sum( \
119+
container_memory_working_set_bytes \
120+
* on(namespace,pod) \
121+
group_left(workload, workload_type) \
122+
namespace_workload_pod:kube_pod_owner:relabel{ workload_type="deployment"}) by (pod)'
122123
123124
```
124125
```
125-
GET https://k8s02-workspace-xy98.eastus.prometheus.monitor.azure.com/api/v1/query?api-version=2021-06-03-preview&query=container_memory_working_set_bytes'
126+
GET 'https://k8s02-workspace-xy98.eastus.prometheus.monitor.azure.com/api/v1/query?query=container_memory_working_set_bytes'
126127
--header 'Authorization: Bearer <access token>'
127128
```
128129
### Range queries
129130
For more information, see [Range queries](https://prometheus.io/docs/prometheus/latest/querying/api/#range-queries)
130131
Path: `/api/v1/query_range`
131132
Examples:
132133
```
133-
GET 'https://k8s02-workspace-xy98.eastus.prometheus.monitor.azure.com/api/v1/query_range?api-version=2021-06-03-preview&query=container_memory_working_set_bytes&start=2023-03-01T20%3A10%3A30.781Z&end=2023-03-20T20%3A11%3A00.781Z&step=6h' \
134+
GET 'https://k8s02-workspace-xy98.eastus.prometheus.monitor.azure.com/api/v1/query_range?query=container_memory_working_set_bytes&start=2023-03-01T00:00:00.000Z&end=2023-03-20T00:00:00.000Z&step=6h'
134135
--header 'Authorization: Bearer <access token>
135136
```
136137

137138
```
138-
POST 'https://k8s02-workspace-xy98.eastus.prometheus.monitor.azure.com/api/v1/query_range?api-version=2021-06-03-preview'
139+
POST 'https://k8s02-workspace-xy98.eastus.prometheus.monitor.azure.com/api/v1/query_range'
139140
--header 'Authorization: Bearer <access token>'
140-
--header 'Content-Type: application/x-www-form-urlencoded' \
141-
--data-urlencode 'query=up' \
142-
--data-urlencode 'start=2023-03-01T20:10:30.781Z' \
143-
--data-urlencode 'end=2023-03-20T20:10:30.781Z' \
141+
--header 'Content-Type: application/x-www-form-urlencoded'
142+
--data-urlencode 'query=up'
143+
--data-urlencode 'start=2023-03-01T20:10:30.781Z'
144+
--data-urlencode 'end=2023-03-20T20:10:30.781Z'
144145
--data-urlencode 'step=6h'
145146
```
146147
### Series
@@ -149,16 +150,14 @@ For more information, see [Series](https://prometheus.io/docs/prometheus/latest/
149150
Path: `/api/v1/series`
150151
Examples:
151152
```
152-
POST 'https://k8s02-workspace-xy98.eastus.prometheus.monitor.azure.com/api/v1/series?api-version=2021-06-03-preview'
153+
POST 'https://k8s02-workspace-xy98.eastus.prometheus.monitor.azure.com/api/v1/series'
153154
--header 'Authorization: Bearer <access token>
154155
--header 'Content-Type: application/x-www-form-urlencoded'
155-
--data-urlencode 'match%5B%5D=container_network_receive_bytes_total'
156156
--data-urlencode 'match%5B%5D=kube_pod_info{pod="bestapp-123abc456d-4nmfm"}'
157157
158158
```
159-
160159
```
161-
GET 'https://k8s02-workspace-xy98.eastus.prometheus.monitor.azure.com/api/v1/series?api-version=2021-06-03-preview&match[]=container_network_receive_bytes_total&match[]=kube_pod_info{pod="bestapp-123abc456d-4nmfm"}'
160+
GET 'https://k8s02-workspace-xy98.eastus.prometheus.monitor.azure.com/api/v1/series?match[]=container_network_receive_bytes_total{namespace="default-1669648428598"}'
162161
```
163162

164163
### Labels
@@ -167,44 +166,46 @@ For more information, see [Labels](https://prometheus.io/docs/prometheus/latest/
167166
Path: `/api/v1/labels`
168167
Examples:
169168
```
170-
GET 'https://k8s02-workspace-xy98.eastus.prometheus.monitor.azure.com/api/v1/labels?api-version=2021-06-03-preview'
169+
GET 'https://k8s02-workspace-xy98.eastus.prometheus.monitor.azure.com/api/v1/labels'
171170
172171
```
173-
174172
```
175-
POST
176-
'https://k8s02-workspace-xy98.eastus.prometheus.monitor.azure.com/api/v1/labels?api-version=2021-06-03-preview'
173+
POST 'https://k8s02-workspace-xy98.eastus.prometheus.monitor.azure.com/api/v1/labels'
177174
```
178175

179176
### Label values
180177
For more information, see [Label values](https://prometheus.io/docs/prometheus/latest/querying/api/#query.ing-label-values)
181-
Path: `/api/v1/label/\_\_name\_\_/values.`
178+
Path: `/api/v1/label/__name__/values.`
182179

183180

184181
> [!NOTE]
185182
> `__name__` is the only supported version of this API and returns all metric names. No other /api/v1/label/<label_name>/values are supported.
186183
187184
Example:
188185
```
189-
GET 'https://k8s02-workspace-xy98.eastus.prometheus.monitor.azure.com/api/v1/label/__name__/values?api-version=2021-06-03-preview'
186+
GET 'https://k8s02-workspace-xy98.eastus.prometheus.monitor.azure.com/api/v1/label/__name__/values'
190187
```
191188

192189
For the full specification of OSS prom APIs, see [Prometheus HTTP API](https://prometheus.io/docs/prometheus/latest/querying/api/#http-api )
193190

194191
## API limitations
195192
(differing from prom specification)
196193
+ Query must be scoped to metric
197-
Any time series fetch queries (/series or /query or /query_range) must contain name label matcher. That is, each query must be scoped to a metric. There can only be one name label matcher in a query.
194+
Any time series fetch queries (/series or /query or /query_range) must contain \_\_name\_\_ label matcher. That is, each query must be scoped to a metric. There can only be one \_\_name\_\_ label matcher in a query.
198195
+ Supported time range
199196
+ /query_range API supports a time range of 32 days. This is the maximum time range allowed including range selectors specified in the query itself.
200-
For example, the query `rate(http_requests_total[5m]` for last 24 hours would actually mean data is being queried for 25 hours. A 24 hours range + 1 hour specified in query itself.
201-
+ /series API fetches data for a maximum 12-hour time range. If `endTime` isn't provided, endTime = time.now(). If yhr time rage is greater than 12 hours, the `startTime` is set to `endTime – 12h`
197+
For example, the query `rate(http_requests_total[1h]` for last 24 hours would actually mean data is being queried for 25 hours. A 24 hours range + 1 hour specified in query itself.
198+
+ /series API fetches data for a maximum 12-hour time range. If `endTime` isn't provided, endTime = time.now(). If the time rage is greater than 12 hours, the `startTime` is set to `endTime – 12h`
202199
+ Ignored time range
203-
Start time and end time provided with /labels and /label/name/values are ignored, and all retained data in the Azure Monitor Workspace is queried.
200+
Start time and end time provided with `/labels` and `/label/__name__/values` are ignored, and all retained data in the Azure Monitor Workspace is queried.
204201
+ Experimental features
205202
Experimental features such as exemplars aren't supported.
206203

207204
For more information on Prometheus metrics limits, see [Prometheus metrics](../../azure-monitor/service-limits.md#prometheus-metrics)
208205

209-
>[!NOTE]
210-
> Some of the limits can be increased. Please contact [PromWebApi](mailto:[email protected]) to request an increase for these limits on your Azure Monitor workspace.
206+
## Next Steps
207+
208+
[Azure Monitor workspace overview (preview)](./azure-monitor-workspace-overview.md)
209+
[Manage an Azure Monitor workspace (preview)](./azure-monitor-workspace-manage.md)
210+
[Overview of Azure Monitor Managed Service for Prometheus (preview)](./prometheus-metrics-overview.md)
211+
[Query Prometheus metrics using Azure workbooks (preview)](./prometheus-workbooks.md)

0 commit comments

Comments
 (0)