diff --git a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_log_query_async.py b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_log_query_async.py index a1697b8494eb..336b6f8d3861 100644 --- a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_log_query_async.py +++ b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_log_query_async.py @@ -3,19 +3,18 @@ """ FILE: sample_logs_single_query_async.py DESCRIPTION: - This sample demonstrates authenticating the LogsQueryClient and querying a single query. + This sample demonstrates authenticating the LogsQueryClient and executing a single + Kusto query. USAGE: python sample_logs_single_query_async.py Set the environment variables with your own values before running the sample: 1) LOGS_WORKSPACE_ID - The first (primary) workspace ID. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. +This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. +For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. -**Note** - Although this example uses pandas to prin the response, it is totally optional and is -not a required package for querying. Alternatively, native python can be used as well. +**Note** - Although this example uses pandas to print the response, it's optional and +isn't a required package for querying. Alternatively, native Python can be used as well. """ import asyncio import os @@ -34,7 +33,7 @@ async def logs_query(): query= """AppRequests | take 5""" try: - response = await client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=timedelta(days=1)) + response = await client.query_workspace(os.environ['LOGS_WORKSPACE_ID'], query, timespan=timedelta(days=1)) if response.status == LogsQueryStatus.PARTIAL: error = response.partial_error data = response.partial_data diff --git a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_definitions_async.py b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_definitions_async.py index dc2aeab0f6dc..1b1ebd8068c7 100644 --- a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_definitions_async.py +++ b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_definitions_async.py @@ -7,13 +7,12 @@ USAGE: python sample_metric_definitions_async.py Set the environment variables with your own values before running the sample: - 1) METRICS_RESOURCE_URI - The resource uri of the resource for which the metrics are being queried. - In this example, an eventgrid account resource URI is taken. + 1) METRICS_RESOURCE_URI - The resource URI of the resource for which the metrics are being queried. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. + This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. + For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. + + In this example, an Event Grid account resource URI is taken. """ import os import asyncio diff --git a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_namespaces_async.py b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_namespaces_async.py index 7418414eb0df..cb6379804589 100644 --- a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_namespaces_async.py +++ b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_namespaces_async.py @@ -7,13 +7,12 @@ USAGE: python sample_metric_namespaces_async.py Set the environment variables with your own values before running the sample: - 1) METRICS_RESOURCE_URI - The resource uri of the resource for which the metrics are being queried. - In this example, a storage account resource URI is taken. + 1) METRICS_RESOURCE_URI - The resource URI of the resource for which the metrics are being queried. + + This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. + For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. + In this example, a Storage account resource URI is taken. """ import os import asyncio diff --git a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metrics_query_async.py b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metrics_query_async.py index 78cad14ff6b9..3ecd89d0a143 100644 --- a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metrics_query_async.py +++ b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metrics_query_async.py @@ -3,18 +3,18 @@ """ FILE: sample_metrics_query_async.py DESCRIPTION: - This sample demonstrates authenticating the LogsQueryClient and querying a single query - on multiple workspaces using the additional_workspaces param. + This sample demonstrates authenticating the MetricsQueryClient and retrieving the "Ingress" + metric along with the "Average" aggregation type. The query will execute over a timespan + of 2 hours with a granularity of 15 minutes. USAGE: python sample_metrics_query_async.py Set the environment variables with your own values before running the sample: - 1) METRICS_RESOURCE_URI - The resource uri of the resource for which the metrics are being queried. - In this example, a storage account resource URI is taken. + 1) METRICS_RESOURCE_URI - The resource URI of the resource for which the metrics are being queried. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. + This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. + For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. + + In this example, a Storage account resource URI is taken. """ import os import asyncio diff --git a/sdk/monitor/azure-monitor-query/samples/sample_batch_query.py b/sdk/monitor/azure-monitor-query/samples/sample_batch_query.py index 95d6f9ac9efe..2963914143e7 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_batch_query.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_batch_query.py @@ -9,13 +9,11 @@ Set the environment variables with your own values before running the sample: 1) LOGS_WORKSPACE_ID - The The first (primary) workspace ID. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. +This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. +For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. -**Note** - Although this example uses pandas to prin the response, it is totally optional and is -not a required package for querying. Alternatively, native python can be used as well. +**Note** - Although this example uses pandas to print the response, it's optional and +isn't a required package for querying. Alternatively, native Python can be used as well. """ from datetime import datetime, timedelta, timezone @@ -24,7 +22,6 @@ from azure.monitor.query import LogsQueryClient, LogsBatchQuery, LogsQueryStatus from azure.identity import DefaultAzureCredential - credential = DefaultAzureCredential() client = LogsQueryClient(credential) @@ -34,18 +31,18 @@ LogsBatchQuery( query="AzureActivity | summarize count()", timespan=timedelta(hours=1), - workspace_id= os.environ['LOG_WORKSPACE_ID'] + workspace_id= os.environ['LOGS_WORKSPACE_ID'] ), LogsBatchQuery( query= """bad query""", timespan=timedelta(days=1), - workspace_id= os.environ['LOG_WORKSPACE_ID'] + workspace_id= os.environ['LOGS_WORKSPACE_ID'] ), LogsBatchQuery( query= """let Weight = 92233720368547758; range x from 1 to 3 step 1 | summarize percentilesw(x, Weight * 100, 50)""", - workspace_id= os.environ['LOG_WORKSPACE_ID'], + workspace_id= os.environ['LOGS_WORKSPACE_ID'], timespan=(datetime(2021, 6, 2, tzinfo=timezone.utc), datetime(2021, 6, 5, tzinfo=timezone.utc)), # (start, end) include_statistics=True ), diff --git a/sdk/monitor/azure-monitor-query/samples/sample_log_query_multiple_workspaces.py b/sdk/monitor/azure-monitor-query/samples/sample_log_query_multiple_workspaces.py index 2a4b86674561..7be747030e92 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_log_query_multiple_workspaces.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_log_query_multiple_workspaces.py @@ -11,13 +11,11 @@ 1) LOGS_WORKSPACE_ID - The first (primary) workspace ID. 2) SECONDARY_WORKSPACE_ID - An additional workspace. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. +This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. +For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. -**Note** - Although this example uses pandas to prin the response, it is totally optional and is -not a required package for querying. Alternatively, native python can be used as well. +**Note** - Although this example uses pandas to print the response, it's optional and +isn't a required package for querying. Alternatively, native Python can be used as well. """ import os import pandas as pd @@ -34,7 +32,7 @@ try: response = client.query_workspace( - os.environ['LOG_WORKSPACE_ID'], + os.environ['LOGS_WORKSPACE_ID'], query, timespan=timedelta(days=1), additional_workspaces=[os.environ['SECONDARY_WORKSPACE_ID']] diff --git a/sdk/monitor/azure-monitor-query/samples/sample_logs_query_key_value_form.py b/sdk/monitor/azure-monitor-query/samples/sample_logs_query_key_value_form.py index 22ec67a6a096..d8877d521388 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_logs_query_key_value_form.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_logs_query_key_value_form.py @@ -10,13 +10,11 @@ Set the environment variables with your own values before running the sample: 1) LOGS_WORKSPACE_ID - The first (primary) workspace ID. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. +This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. +For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. -**Note** - Although this example uses pandas to prin the response, it is totally optional and is -not a required package for querying. Alternatively, native python can be used as well. +**Note** - Although this example uses pandas to print the response, it's optional and +isn't a required package for querying. Alternatively, native Python can be used as well. """ import os import pandas as pd @@ -33,7 +31,7 @@ query= """AppRequests | take 5""" try: - response = client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=timedelta(days=1)) + response = client.query_workspace(os.environ['LOGS_WORKSPACE_ID'], query, timespan=timedelta(days=1)) if response.status == LogsQueryStatus.PARTIAL: error = response.partial_error data = response.partial_data diff --git a/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query.py b/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query.py index 0e163ea06f78..7b62b2d2c361 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query.py @@ -9,13 +9,11 @@ Set the environment variables with your own values before running the sample: 1) LOGS_WORKSPACE_ID - The first (primary) workspace ID. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. +This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. +For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. -**Note** - Although this example uses pandas to prin the response, it is totally optional and is -not a required package for querying. Alternatively, native python can be used as well. +**Note** - Although this example uses pandas to print the response, it's optional and +isn't a required package for querying. Alternatively, native Python can be used as well. """ import os import pandas as pd @@ -34,7 +32,7 @@ query= """AppRequests | take 5""" try: - response = client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=timedelta(days=1)) + response = client.query_workspace(os.environ['LOGS_WORKSPACE_ID'], query, timespan=timedelta(days=1)) if response.status == LogsQueryStatus.PARTIAL: error = response.partial_error data = response.partial_data diff --git a/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query_partial_result.py b/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query_partial_result.py index 6c0d41a575a7..9830c426c961 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query_partial_result.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query_partial_result.py @@ -10,13 +10,11 @@ Set the environment variables with your own values before running the sample: 1) LOGS_WORKSPACE_ID - The first (primary) workspace ID. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. +This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. +For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. -**Note** - Although this example uses pandas to prin the response, it is totally optional and is -not a required package for querying. Alternatively, native python can be used as well. +**Note** - Although this example uses pandas to print the response, it's optional and +isn't a required package for querying. Alternatively, native Python can be used as well. """ import os import pandas as pd @@ -37,7 +35,7 @@ # this block of code is exactly the same whether the expected result is a success, a failure or a # partial success try: - response = client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=timedelta(days=1)) + response = client.query_workspace(os.environ['LOGS_WORKSPACE_ID'], query, timespan=timedelta(days=1)) if response.status == LogsQueryStatus.PARTIAL: # handle error here error = response.partial_error diff --git a/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py b/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py index 8ab1778a2c85..74b7ef45c88e 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py @@ -7,13 +7,12 @@ USAGE: python sample_metric_definitions.py Set the environment variables with your own values before running the sample: - 1) METRICS_RESOURCE_URI - The resource uri of the resource for which the metrics are being queried. - In this example, an eventgrid account resource URI is taken. + 1) METRICS_RESOURCE_URI - The resource URI of the resource for which the metrics are being queried. + + This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. + For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. + In this example, an Event Grid account resource URI is taken. """ import os from azure.monitor.query import MetricsQueryClient diff --git a/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py b/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py index ccc51bbf0fb6..2a03b6ad421d 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py @@ -7,13 +7,12 @@ USAGE: python sample_metric_namespaces.py Set the environment variables with your own values before running the sample: - 1) METRICS_RESOURCE_URI - The resource uri of the resource for which the metrics are being queried. - In this example, a storage account resource URI is taken. + 1) METRICS_RESOURCE_URI - The resource URI of the resource for which the metrics are being queried. + + This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. + For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. + In this example, a Storage account resource URI is taken. """ import os from azure.monitor.query import MetricsQueryClient diff --git a/sdk/monitor/azure-monitor-query/samples/sample_metrics_query.py b/sdk/monitor/azure-monitor-query/samples/sample_metrics_query.py index 0c1844b59792..434fe860b933 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_metrics_query.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_metrics_query.py @@ -3,18 +3,18 @@ """ FILE: sample_metrics_query.py DESCRIPTION: - This sample demonstrates authenticating the LogsQueryClient and querying a single query - on multiple workspaces using the additional_workspaces param. + This sample demonstrates authenticating the MetricsQueryClient and retrieving the "Ingress" + metric along with the "Average" aggregation type. The query will execute over a timespan + of 2 hours with a granularity of 5 minutes. USAGE: python sample_metrics_query.py Set the environment variables with your own values before running the sample: 1) METRICS_RESOURCE_URI - The resource uri of the resource for which the metrics are being queried. - In this example, a storage account resource URI is taken. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. + This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. + For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. + + In this example, a Storage account resource URI is taken. """ import os from datetime import timedelta diff --git a/sdk/monitor/azure-monitor-query/samples/sample_server_timeout.py b/sdk/monitor/azure-monitor-query/samples/sample_server_timeout.py index 812091440925..354dbfc7a60d 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_server_timeout.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_server_timeout.py @@ -3,19 +3,17 @@ """ FILE: sample_server_timeout.py DESCRIPTION: - This sample demostrates how to update a server timeout for a long running query. + This sample demonstrates how to update a server timeout for a long running query. USAGE: python sample_server_timeout.py Set the environment variables with your own values before running the sample: 1) LOGS_WORKSPACE_ID - The first (primary) workspace ID. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. +This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. +For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. -**Note** - Although this example uses pandas to prin the response, it is totally optional and is -not a required package for querying. Alternatively, native python can be used as well. +**Note** - Although this example uses pandas to print the response, it's optional and +isn't a required package for querying. Alternatively, native Python can be used as well. """ import os import pandas as pd @@ -32,7 +30,7 @@ try: response = client.query_workspace( - os.environ['LOG_WORKSPACE_ID'], + os.environ['LOGS_WORKSPACE_ID'], query, timespan=timedelta(days=1), server_timeout=3 diff --git a/sdk/monitor/azure-monitor-query/samples/sample_single_log_query_without_pandas.py b/sdk/monitor/azure-monitor-query/samples/sample_single_log_query_without_pandas.py index 5f8a9f09fafd..a6aefb3aa6cb 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_single_log_query_without_pandas.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_single_log_query_without_pandas.py @@ -10,10 +10,8 @@ Set the environment variables with your own values before running the sample: 1) LOGS_WORKSPACE_ID - The first (primary) workspace ID. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. +This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. +For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. """ import os from datetime import timedelta @@ -27,9 +25,8 @@ query= """AppRequests | take 5""" - try: - response = client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=timedelta(days=1)) + response = client.query_workspace(os.environ['LOGS_WORKSPACE_ID'], query, timespan=timedelta(days=1)) if response.status == LogsQueryStatus.PARTIAL: # handle error here error = response.partial_error