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
@@ -128,6 +128,39 @@ Each set of metric values is a time series with the following characteristics:
128
128
129
129
This example shows how to query a Log Analytics workspace. To handle the response and view it in a tabular form, the [`pandas`](https://pypi.org/project/pandas/) library is used. See the [samples][samples] if you choose not to use `pandas`.
130
130
131
+
#### Resource-centric logs query
132
+
133
+
The following example demonstrates how to query logs directly from an Azure resource without the use of a Log Analytics workspace. Here, the `query_resource` method is used instead of `query_workspace`. Instead of a workspace ID, an Azure resource identifier is passed in. For example, `/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}`.
134
+
135
+
```python
136
+
import os
137
+
import pandas as pd
138
+
from datetime import timedelta
139
+
from azure.monitor.query import LogsQueryClient, LogsQueryStatus
140
+
from azure.core.exceptions import HttpResponseError
The `timespan` parameter specifies the time duration for which to query the data. This value can take one of the following forms:
@@ -278,39 +311,6 @@ for res in results:
278
311
279
312
```
280
313
281
-
### Resource logs query
282
-
283
-
The following example demonstrates how to query logs directly from an Azure resource without the use of a Log Analytics workspace. Here, the `query_resource` method is used instead of `query_workspace`. Instead of a workspace ID, an Azure resource identifier is passed in. For example, `/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}`.
284
-
285
-
```python
286
-
import os
287
-
import pandas as pd
288
-
from datetime import timedelta
289
-
from azure.monitor.query import LogsQueryClient, LogsQueryStatus
290
-
from azure.core.exceptions import HttpResponseError
@@ -362,7 +362,7 @@ A full sample can be found [here](https://github.com/Azure/azure-sdk-for-python/
362
362
To get logs query execution statistics, such as CPU and memory consumption:
363
363
364
364
1. Set the `include_statistics` parameter to `True`.
365
-
2. Access the `statistics` field inside the `LogsQueryResult` object.
365
+
1. Access the `statistics` field inside the `LogsQueryResult` object.
366
366
367
367
The following example prints the query execution time:
368
368
@@ -546,7 +546,10 @@ Each Azure resource must reside in:
546
546
- The same region as the endpoint specified when creating the client.
547
547
- The same Azure subscription.
548
548
549
-
Furthermore, the metric namespace containing the metrics to be queried must be provided. For a list of metric namespaces, see [Supported metrics and log categories by resource type][metric_namespaces].
549
+
Furthermore:
550
+
551
+
- The user must be authorized to read monitoring data at the Azure subscription level. For example, the [Monitoring Reader role](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles/monitor#monitoring-reader) on the subscription to be queried.
552
+
- The metric namespace containing the metrics to be queried must be provided. For a list of metric namespaces, see [Supported metrics and log categories by resource type][metric_namespaces].
0 commit comments