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
- Renamed the client to `MetricsClient`.
- Renamed `query_batch` to `query_resources`
- Made `query_resources` positional arguments keyword only
Signed-off-by: Paul Van Eck <[email protected]>
Copy file name to clipboardExpand all lines: sdk/monitor/azure-monitor-query/CHANGELOG.md
+4-3Lines changed: 4 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,14 @@
4
4
5
5
### Features Added
6
6
7
-
- Added `roll_up_by` keyword argument to `MetricsBatchQueryClient.query_batch` to support rolling up metrics by dimension. ([#33752](https://github.com/Azure/azure-sdk-for-python/pull/33752))
7
+
- Added `roll_up_by` keyword argument to `MetricsClient.query_resources` to support rolling up metrics by dimension. ([#33752](https://github.com/Azure/azure-sdk-for-python/pull/33752))
8
8
9
9
### Breaking Changes
10
10
11
11
- The following changes are breaking against the previous preview release (i.e. `1.3.0b2`/`1.3.0b1`):
12
-
- Reordered the arguments for the async `MetricsBatchQueryClient` constructor so that `endpoint` is now the first positional argument. ([#33752](https://github.com/Azure/azure-sdk-for-python/pull/33752))
13
-
- Reordered the `metric_names` and `metric_namespace` positional arguments in `MetricsBatchQueryClient.query_batch`. ([#33752](https://github.com/Azure/azure-sdk-for-python/pull/33752))
12
+
-`MetricsBatchQueryClient` has been renamed to `MetricsClient`. ([#33958](https://github.com/Azure/azure-sdk-for-python/pull/33958))
13
+
- Reordered the arguments for the async `MetricsClient` constructor so that `endpoint` is now the first positional argument. ([#33752](https://github.com/Azure/azure-sdk-for-python/pull/33752))
14
+
- Positional arguments in `MetricsClient.query_resources` are now required keyword-only arguments. ([#33958](https://github.com/Azure/azure-sdk-for-python/pull/33958))
Copy file name to clipboardExpand all lines: sdk/monitor/azure-monitor-query/README.md
+20-15Lines changed: 20 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ The Azure Monitor Query client library is used to execute read-only queries agai
19
19
20
20
### Prerequisites
21
21
22
-
- Python 3.7 or later
22
+
- Python 3.8 or later
23
23
- An [Azure subscription][azure_subscription]
24
24
- A [TokenCredential](https://learn.microsoft.com/python/api/azure-core/azure.core.credentials.tokencredential?view=azure-python) implementation, such as an [Azure Identity library credential type](https://learn.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#credential-classes).
25
25
- To query Logs, you need one of the following things:
An authenticated client is required to query Logs or Metrics. The library includes both synchronous and asynchronous forms of the clients. To authenticate, create an instance of a token credential. Use that instance when creating a `LogsQueryClient`, `MetricsQueryClient`, or `MetricsBatchQueryClient`. The following examples use `DefaultAzureCredential` from the [azure-identity](https://pypi.org/project/azure-identity/) package.
40
+
An authenticated client is required to query Logs or Metrics. The library includes both synchronous and asynchronous forms of the clients. To authenticate, create an instance of a token credential. Use that instance when creating a `LogsQueryClient`, `MetricsQueryClient`, or `MetricsClient`. The following examples use `DefaultAzureCredential` from the [azure-identity](https://pypi.org/project/azure-identity/) package.
41
41
42
42
#### Synchronous clients
43
43
44
44
Consider the following example, which creates synchronous clients for both Logs and Metrics querying:
45
45
46
46
```python
47
47
from azure.identity import DefaultAzureCredential
48
-
from azure.monitor.query import LogsQueryClient, MetricsQueryClient
48
+
from azure.monitor.query import LogsQueryClient, MetricsQueryClient, MetricsClient
#### Configure clients for non-public Azure clouds
69
72
70
73
By default, `LogsQueryClient` and `MetricsQueryClient` are configured to connect to the public Azure cloud. These can be configured to connect to non-public Azure clouds by passing in the correct `endpoint` argument: For example:
**Note**: Currently, `MetricsQueryClient` uses the Azure Resource Manager (ARM) endpoint for querying metrics, so you will need the corresponding management endpoint for your cloud when using this client. This is subject to change in the future.
@@ -114,6 +117,7 @@ Each set of metric values is a time series with the following characteristics:
-[Example of handling response](#example-of-handling-response)
120
+
-[Metrics batch query](#metrics-batch-query)
117
121
118
122
### Logs query
119
123
@@ -527,7 +531,7 @@ for metric in response.metrics:
527
531
528
532
### Metrics batch query
529
533
530
-
A user can also query metrics from multiple resources at once using the `query_batch` method of `MetricsBatchQueryClient`. This uses a different API than the `MetricsQueryClient` and requires that a user pass in a regional endpoint when instantiating the client (for example, "https://westus3.metrics.monitor.azure.com").
534
+
A user can also query metrics from multiple resources at once using the `query_resources` method of `MetricsClient`. This uses a different API than the `MetricsQueryClient` and requires that a user pass in a regional endpoint when instantiating the client (for example, "https://westus3.metrics.monitor.azure.com").
531
535
532
536
Note, each resource must be in the same region as the endpoint passed in when instantiating the client, and each resource must be in the same Azure subscription. Furthermore, the metric namespace that contains the metrics to be queried must also be passed. A list of metric namespaces can be found [here][metric_namespaces].
533
537
@@ -538,19 +542,19 @@ import os
538
542
539
543
from azure.core.exceptions import HttpResponseError
540
544
from azure.identity import DefaultAzureCredential
541
-
from azure.monitor.query importMetricsBatchQueryClient, MetricAggregationType
545
+
from azure.monitor.query importMetricsClient, MetricAggregationType
@@ -586,6 +590,7 @@ The following code samples show common scenarios with the Azure Monitor Query cl
586
590
#### Metrics query samples
587
591
588
592
-[Send a query using MetricsQueryClient](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_metrics_query.py) ([async sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metrics_query_async.py))
593
+
-[Send a query to multiple resources in a region and subscription using MetricsClient](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_metrics_query_multiple.py) ([async sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metrics_query_multiple_async.py))
589
594
-[Get a list of metric namespaces](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py) ([async sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_namespaces_async.py))
590
595
-[Get a list of metric definitions](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py) ([async sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_definitions_async.py))
Copy file name to clipboardExpand all lines: sdk/monitor/azure-monitor-query/samples/README.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -35,13 +35,13 @@ For examples on authenticating with the Azure Monitor service, see [sample_authe
35
35
### Metrics query samples
36
36
37
37
-[Send a query using MetricsQueryClient](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_metrics_query.py) ([async sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metrics_query_async.py))
38
-
-[Send a batch of queries using MetricBatchQueryClient](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_metrics_batch_query.py) ([async sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metrics_batch_query_async.py))
38
+
-[Send a query to multiple resources at once using MetricsClient](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_metrics_query_multiple.py) ([async sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metrics_query_multiple_async.py))
39
39
-[Get a list of metric namespaces](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py) ([async sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_namespaces_async.py))
40
40
-[Get a list of metric definitions](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py) ([async sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_definitions_async.py))
41
41
42
42
## Prerequisites
43
43
44
-
- Python 3.7 or later
44
+
- Python 3.8 or later
45
45
- An [Azure subscription][azure_subscription]
46
46
- To query Logs, you need an [Azure Log Analytics workspace][azure_monitor_create_using_portal].
47
47
- To query Metrics, you need an Azure resource of any kind (Storage Account, Key Vault, Cosmos DB, etc.).
0 commit comments