Skip to content

Commit 34baeca

Browse files
committed
[Monitor] Update query package to use TypeSpec
This removes Metrics-related code/content and converts this package to be for logs querying only. Signed-off-by: Paul Van Eck <[email protected]>
1 parent 5ce5f9a commit 34baeca

File tree

120 files changed

+3169
-15203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+3169
-15203
lines changed

sdk/monitor/azure-monitor-query/CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
# Release History
22

3-
## 1.4.2 (Unreleased)
3+
## 2.0.0 (Unreleased)
44

55
### Features Added
66

77
### Breaking Changes
88

9+
- `MetricsClient` and `MetricsQueryClient` have been removed from the `azure-monitor-query` package. This is part of the migration to split logs and metrics functionality into separate packages. ([#42205](https://github.com/Azure/azure-sdk-for-python/pull/42205))
10+
- The `MetricsClient` has been moved to the new `azure-monitor-querymetrics`
11+
- Functionality provided by `MetricsQueryClient` can be access through the `azure-mgmt-monitor` package.
12+
913
### Bugs Fixed
1014

1115
- Fixed an issue where the package version in operation user agent strings was always set to "unknown" instead of the actual package version. ([#39866](https://github.com/Azure/azure-sdk-for-python/pull/39866))
1216

1317
### Other Changes
1418

19+
- Bump minimum dependencies:
20+
- `azure-core` to `>=1.30.0`
21+
- `isodate` to `>=0.6.1`
22+
- `typing-extensions` to `>=4.6.0`
23+
1524
## 1.4.1 (2025-01-14)
1625

1726
### Other Changes
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
recursive-include tests *.py *.yaml
2-
recursive-include samples *.py
31
include *.md
42
include LICENSE
3+
include azure/monitor/query/py.typed
4+
recursive-include tests *.py
5+
recursive-include samples *.py *.md
56
include azure/__init__.py
67
include azure/monitor/__init__.py
7-
include azure/monitor/query/py.typed

sdk/monitor/azure-monitor-query/README.md

Lines changed: 12 additions & 182 deletions
Large diffs are not rendered by default.

sdk/monitor/azure-monitor-query/TROUBLESHOOTING.md

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@ This troubleshooting guide contains instructions to diagnose frequently encounte
66

77
* [General Troubleshooting](#general-troubleshooting)
88
* [Enable client logging](#enable-client-logging)
9-
* [Troubleshooting authentication issues with logs and metrics query requests](#authentication-errors)
9+
* [Troubleshooting authentication issues with query requests](#authentication-errors)
1010
* [Troubleshooting running async APIs](#errors-with-running-async-apis)
1111
* [Troubleshooting Logs Query](#troubleshooting-logs-query)
1212
* [Troubleshooting insufficient access error](#troubleshooting-insufficient-access-error-for-logs-query)
1313
* [Troubleshooting invalid Kusto query](#troubleshooting-invalid-kusto-query)
1414
* [Troubleshooting empty log query results](#troubleshooting-empty-log-query-results)
1515
* [Troubleshooting server timeouts when executing logs query request](#troubleshooting-server-timeouts-when-executing-logs-query-request)
1616
* [Troubleshooting partially successful logs query requests](#troubleshooting-partially-successful-logs-query-requests)
17-
* [Troubleshooting Metrics Query](#troubleshooting-metrics-query)
18-
* [Troubleshooting insufficient access error](#troubleshooting-insufficient-access-error-for-metrics-query)
19-
* [Troubleshooting unsupported granularity for metrics query](#troubleshooting-unsupported-granularity-for-metrics-query)
2017
* [Additional azure-core configurations](#additional-azure-core-configurations)
2118

2219
## General Troubleshooting
@@ -53,11 +50,7 @@ client.query_workspace(logging_enable=True)
5350

5451
### Authentication errors
5552

56-
Azure Monitor Query supports Azure Active Directory authentication. Both LogsQueryClient and
57-
MetricsQueryClient have methods to set the `credential`. To provide a valid credential, you can use
58-
`azure-identity` dependency. For more details on getting started, refer to
59-
the [README](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/monitor/azure-monitor-query#create-the-client)
60-
of Azure Monitor Query library. You can also refer to
53+
Azure Monitor Query supports Microsoft Entra ID authentication. LogsQueryClient has methods to set the `credential`. To provide a valid credential, you can use the `azure-identity` package. For more details on getting started, refer to the [README](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/monitor/azure-monitor-query#create-the-client) of the Azure Monitor Query library. You can also refer to
6154
the [Azure Identity documentation](https://learn.microsoft.com/python/api/overview/azure/identity-readme)
6255
for more details on the various types of credential supported in `azure-identity`.
6356

@@ -174,39 +167,6 @@ data = response.partial_data
174167
error = response.partial_error
175168
```
176169

177-
## Troubleshooting Metrics Query
178-
179-
### Troubleshooting insufficient access error for metrics query
180-
181-
If you get an HTTP error with status code 403 (Forbidden), it means that the provided credentials does not have
182-
sufficient permissions to query the workspace.
183-
```text
184-
"{"error":{"message":"The provided credentials have insufficient access to perform the requested operation","code":"InsufficientAccessError","correlationId":""}}"
185-
```
186-
187-
1. Check that the application or user that is making the request has sufficient permissions:
188-
* You can refer to this document to [manage access to workspaces](https://learn.microsoft.com/azure/azure-monitor/logs/manage-access#manage-access-using-workspace-permissions)
189-
2. If the user or application is granted sufficient privileges to query the workspace, make sure you are
190-
authenticating as that user/application. If you are authenticating using the
191-
[DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#defaultazurecredential)
192-
then check the logs to verify that the credential used is the one you expected. To enable logging, see [enable
193-
client logging](#enable-client-logging) section above.
194-
195-
For more help on troubleshooting authentication errors please see the Azure Identity client library [troubleshooting guide](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/identity/azure-identity/TROUBLESHOOTING.md).
196-
197-
### Troubleshooting unsupported granularity for metrics query
198-
199-
If you notice the following exception, this is due to an invalid time granularity in the metrics query request. Your
200-
query might have set the `granularity` keyword argument to an unsupported duration.
201-
202-
```text
203-
"{"code":"BadRequest","message":"Invalid time grain duration: PT10M, supported ones are: 00:01:00,00:05:00,00:15:00,00:30:00,01:00:00,06:00:00,12:00:00,1.00:00:00"}"
204-
```
205-
206-
As documented in the error message, the supported granularity for metrics queries are 1 minute, 5 minutes, 15 minutes,
207-
30 minutes, 1 hour, 6 hours, 12 hours and 1 day.
208-
209-
210170
## Additional azure-core configurations
211171

212172
When calling the methods, some properties including `retry_mode`, `timeout`, `connection_verify` can be configured by passing in as keyword arguments. See
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"apiVersion": "v1"
3+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"CrossLanguagePackageId": "MonitorQueryLogs",
3+
"CrossLanguageDefinitionId": {
4+
"azure.monitor.query.models._ColumnType": "MonitorQueryLogs.ColumnDataType"
5+
}
6+
}

sdk/monitor/azure-monitor-query/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/monitor/azure-monitor-query",
5-
"Tag": "python/monitor/azure-monitor-query_79499b2a8c"
5+
"Tag": "python/monitor/azure-monitor-query_5e44a95839"
66
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore

sdk/monitor/azure-monitor-query/azure/monitor/query/__init__.py

Lines changed: 18 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,31 @@
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
44
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
57
# --------------------------------------------------------------------------
8+
# pylint: disable=wrong-import-position
69

7-
from ._logs_query_client import LogsQueryClient
8-
from ._metrics_query_client import MetricsQueryClient
9-
from ._metrics_client import MetricsClient
10+
from typing import TYPE_CHECKING
1011

11-
from ._enums import (
12-
LogsQueryStatus,
13-
MetricAggregationType,
14-
MetricClass,
15-
MetricNamespaceClassification,
16-
MetricUnit,
17-
)
12+
if TYPE_CHECKING:
13+
from ._patch import * # pylint: disable=unused-wildcard-import
1814

19-
from ._exceptions import LogsQueryError
15+
from ._client import MonitorQueryLogsClient # type: ignore
16+
from ._version import VERSION
2017

21-
from ._models import (
22-
LogsQueryResult,
23-
LogsTable,
24-
LogsQueryPartialResult,
25-
LogsTableRow,
26-
MetricsQueryResult,
27-
LogsBatchQuery,
28-
MetricNamespace,
29-
MetricDefinition,
30-
TimeSeriesElement,
31-
Metric,
32-
MetricValue,
33-
MetricAvailability,
34-
)
18+
__version__ = VERSION
3519

36-
from ._version import VERSION
20+
try:
21+
from ._patch import __all__ as _patch_all
22+
from ._patch import *
23+
except ImportError:
24+
_patch_all = []
25+
from ._patch import patch_sdk as _patch_sdk
3726

3827
__all__ = [
39-
"MetricAggregationType",
40-
"LogsQueryClient",
41-
"LogsQueryResult",
42-
"LogsQueryPartialResult",
43-
"LogsQueryStatus",
44-
"LogsQueryError",
45-
"LogsTable",
46-
"LogsTableRow",
47-
"LogsBatchQuery",
48-
"MetricsQueryClient",
49-
"MetricsClient",
50-
"MetricNamespace",
51-
"MetricNamespaceClassification",
52-
"MetricDefinition",
53-
"MetricUnit",
54-
"MetricsQueryResult",
55-
"TimeSeriesElement",
56-
"Metric",
57-
"MetricValue",
58-
"MetricClass",
59-
"MetricAvailability",
28+
"MonitorQueryLogsClient",
6029
]
30+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
6131

62-
__version__ = VERSION
32+
_patch_sdk()

0 commit comments

Comments
 (0)