Skip to content

Commit 84214fb

Browse files
authored
Update Monitor Query README and logs query client comments (Azure#20933)
1 parent b9211fb commit 84214fb

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

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

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ For examples of Logs and Metrics queries, see the [Examples](#examples) section.
7171

7272
The Log Analytics service applies throttling when the request rate is too high. Limits, such as the maximum number of rows returned, are also applied on the Kusto queries. For more information, see [Rate and query limits](https://dev.loganalytics.io/documentation/Using-the-API/Limits).
7373

74+
If you're executing a batch logs query, a throttled request will return a `LogsQueryError` object. That object's `code` value will be `ThrottledError`.
75+
7476
### Metrics data structure
7577

7678
Each set of metric values is a time series with the following characteristics:
@@ -101,7 +103,13 @@ This example shows getting a logs query. To handle the response and view it in a
101103

102104
#### Specify timespan
103105

104-
The `timespan` parameter specifies the time duration for which to query the data. The timespan for which to query the data. This can be a timedelta, a timedelta and a start datetime, or a start datetime/end datetime. For example:
106+
The `timespan` parameter specifies the time duration for which to query the data. This value can be one of the following:
107+
108+
- a `timedelta`
109+
- a `timedelta` and a start datetime
110+
- a start datetime/end datetime
111+
112+
For example:
105113

106114
```python
107115
import os
@@ -152,11 +160,13 @@ LogsQueryResult
152160
|---columns
153161
|---column_types
154162
155-
156163
LogsQueryPartialResult
157164
|---statistics
158165
|---visualization
159166
|---partial_error (a `LogsQueryError` object)
167+
|---code
168+
|---message
169+
|---status
160170
|---partial_data (list of `LogsTable` objects)
161171
|---name
162172
|---rows
@@ -247,7 +257,6 @@ The following example shows setting a server timeout in seconds. A gateway timeo
247257

248258
```python
249259
import os
250-
import pandas as pd
251260
from azure.monitor.query import LogsQueryClient
252261
from azure.identity import DefaultAzureCredential
253262

@@ -347,7 +356,6 @@ MetricsResult
347356

348357
```python
349358
import os
350-
from datetime import datetime, timedelta
351359
from azure.monitor.query import MetricsQueryClient, MetricAggregationType
352360
from azure.identity import DefaultAzureCredential
353361

@@ -395,25 +403,23 @@ Optional keyword arguments can be passed in at the client and per-operation leve
395403
To learn more about Azure Monitor, see the [Azure Monitor service documentation][azure_monitor_overview].
396404

397405
### Samples
398-
These code samples show common champion scenario operations with the Azure Monitor Query client library.
399-
400-
* Send a single query with LogsQueryClient and handle the response as a table: [sample_logs_single_query.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query.py) ([async_sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/async_samples/sample_log_query_async.py))
401-
402-
* Send a single query with LogsQueryClient and handle the response in key value form: [sample_logs_query_key_value_form.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_logs_query_key_value_form.py)
403-
404-
* Send a single query with LogsQueryClient without pandas: [sample_single_log_query_without_pandas.py.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_single_log_query_without_pandas.py)
405-
406-
* Send a single query with LogsQueryClient across multiple workspaces: [sample_logs_query_multiple_workspaces.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_log_query_multiple_workspaces.py)
407406

408-
* Send multiple queries with LogsQueryClient: [sample_batch_query.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_batch_query.py)
407+
The following code samples show common scenarios with the Azure Monitor Query client library.
409408

410-
* Send a single query with LogsQueryClient using server timeout: [sample_server_timeout.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_server_timeout.py)
409+
#### Logs query samples
411410

412-
* Send a query using MetricsQueryClient: [sample_metrics_query.py](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))
411+
- [Send a single query with LogsQueryClient and handle the response as a table](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query.py) ([async sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/async_samples/sample_log_query_async.py))
412+
- [Send a single query with LogsQueryClient and handle the response in key-value form](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_logs_query_key_value_form.py)
413+
- [Send a single query with LogsQueryClient without pandas](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_single_log_query_without_pandas.py)
414+
- [Send a single query with LogsQueryClient across multiple workspaces](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_log_query_multiple_workspaces.py)
415+
- [Send multiple queries with LogsQueryClient](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_batch_query.py)
416+
- [Send a single query with LogsQueryClient using server timeout](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_server_timeout.py)
413417

414-
* Get a list of metric namespaces: [sample_metric_namespaces.py](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))
418+
#### Metrics query samples
415419

416-
* Get a list of metric definitions: [sample_metric_definitions.py](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))
420+
- [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))
421+
- [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))
422+
- [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))
417423

418424
## Contributing
419425

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ def __init__(self, credential, **kwargs):
6666
@distributed_trace
6767
def query_workspace(self, workspace_id, query, **kwargs):
6868
# type: (str, str, Any) -> Union[LogsQueryResult, LogsQueryPartialResult]
69-
"""Execute an Analytics query.
69+
"""Execute a Kusto query.
7070
71-
Executes an Analytics query for data.
71+
Executes a Kusto query for data.
7272
7373
:param workspace_id: ID of the workspace. This is Workspace ID from the Properties blade in the
7474
Azure portal.
@@ -146,7 +146,7 @@ def query_batch(
146146
**kwargs # type: Any
147147
):
148148
# type: (...) -> List[Union[LogsQueryResult, LogsQueryPartialResult, LogsQueryError]]
149-
"""Execute a list of analytics queries. Each request can be either a LogsBatchQuery
149+
"""Execute a list of Kusto queries. Each request can be either a LogsBatchQuery
150150
object or an equivalent serialized model.
151151
152152
**NOTE**: The response is returned in the same order as that of the requests sent.

0 commit comments

Comments
 (0)