From 990d5284d9b107802432946f4a516aa5a5ab9e89 Mon Sep 17 00:00:00 2001 From: Srikanta <51379715+srnagar@users.noreply.github.com> Date: Thu, 16 Sep 2021 12:36:34 -0700 Subject: [PATCH] API consistency review updates (#24130) * API consistency review updates * update type names * revert experimental changes * Fix codesnippet name --- sdk/monitor/azure-monitor-query/README.md | 68 ++--- .../monitor/query/LogsQueryAsyncClient.java | 36 ++- .../azure/monitor/query/LogsQueryClient.java | 18 +- .../query/MetricsQueryAsyncClient.java | 8 +- .../logs/AzureLogAnalyticsImplBuilder.java | 6 +- .../logs/models/LogsQueryHelper.java | 22 ++ .../monitor/query/models/LogsBatchQuery.java | 7 +- .../query/models/LogsBatchQueryResult.java | 16 +- .../query/models/LogsQueryOptions.java | 22 ++ .../monitor/query/models/LogsQueryResult.java | 18 ++ .../query/models/LogsQueryResultStatus.java | 13 + .../query/models/MetricsQueryOptions.java | 7 +- .../query/models/MetricsQueryResult.java | 7 +- .../query/models/QueryTimeInterval.java | 239 ++++++++++++++++++ .../monitor/query/LogsQueryWithModels.java | 4 +- .../monitor/query/MetricsQuerySample.java | 4 +- .../azure/monitor/query/ReadmeSamples.java | 19 +- .../LogsQueryClientJavaDocCodeSnippets.java | 39 +-- .../monitor/query/LogsQueryClientTest.java | 13 +- .../monitor/query/MetricsQueryClientTest.java | 4 +- ...ientTest.testBatchQueryPartialSuccess.json | 4 +- ...gsQueryClientTest.testBatchStatistics.json | 4 +- .../LogsQueryClientTest.testLogsQuery.json | 4 +- ...ogsQueryClientTest.testLogsQueryBatch.json | 4 +- ...ueryClientTest.testMultipleWorkspaces.json | 4 +- ...LogsQueryClientTest.testServerTimeout.json | 8 +- .../LogsQueryClientTest.testStatistics.json | 4 +- 27 files changed, 463 insertions(+), 139 deletions(-) create mode 100644 sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryResultStatus.java create mode 100644 sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/QueryTimeInterval.java diff --git a/sdk/monitor/azure-monitor-query/README.md b/sdk/monitor/azure-monitor-query/README.md index 4ce341af78353..d652a68e06a0f 100644 --- a/sdk/monitor/azure-monitor-query/README.md +++ b/sdk/monitor/azure-monitor-query/README.md @@ -46,16 +46,26 @@ An authenticated client is required to query Logs or Metrics. The library includ ```java -LogsQueryClient logsQueryClient = new LogsQueryClientBuilder() +public void createLogsClients() { + LogsQueryClient logsQueryClient = new LogsQueryClientBuilder() + .credential(new DefaultAzureCredentialBuilder().build()) +``` + +### Create Logs query async client + + +```java + +LogsQueryAsyncClient logsQueryAsyncClient = new LogsQueryClientBuilder() .credential(new DefaultAzureCredentialBuilder().build()) - .buildClient(); ``` +### Create Metrics query client ```java -MetricsQueryClient metricsQueryClient = new MetricsQueryClientBuilder() - .credential(new DefaultAzureCredentialBuilder().build()) - .buildClient(); +public void createMetricsClients() { + MetricsQueryClient metricsQueryClient = new MetricsQueryClientBuilder() + .credential(new DefaultAzureCredentialBuilder().build()) ``` #### Asynchronous clients @@ -69,9 +79,9 @@ LogsQueryAsyncClient logsQueryAsyncClient = new LogsQueryClientBuilder() ```java + MetricsQueryAsyncClient metricsQueryAsyncClient = new MetricsQueryClientBuilder() .credential(new DefaultAzureCredentialBuilder().build()) - .buildAsyncClient(); ``` ### Execute the query @@ -118,48 +128,48 @@ Each set of metric values is a time series with the following characteristics: ```java +ic void queryLogs() { LogsQueryClient logsQueryClient = new LogsQueryClientBuilder() .credential(new DefaultAzureCredentialBuilder().build()) .buildClient(); LogsQueryResult queryResults = logsQueryClient.query("{workspace-id}", "{kusto-query}", - new TimeInterval(Duration.ofDays(2))); + new QueryTimeInterval(Duration.ofDays(2))); for (LogsTableRow row : queryResults.getTable().getRows()) { System.out.println(row.getColumnValue("OperationName") + " " + row.getColumnValue("ResourceGroup")); -} ``` #### Map logs query results to a model ```java -public class CustomLogModel { - private String resourceGroup; - private String operationName; - public String getResourceGroup() { - return resourceGroup; - } +ic class CustomLogModel { +private String resourceGroup; +private String operationName; - public String getOperationName() { - return operationName; - } +public String getResourceGroup() { + return resourceGroup; +} + +public String getOperationName() { + return operationName; } ``` ```java +ic void queryLogsAsModel() { LogsQueryClient logsQueryClient = new LogsQueryClientBuilder() .credential(new DefaultAzureCredentialBuilder().build()) .buildClient(); List customLogModels = logsQueryClient.query("{workspace-id}", "{kusto-query}", - new TimeInterval(Duration.ofDays(2)), CustomLogModel.class); + new QueryTimeInterval(Duration.ofDays(2)), CustomLogModel.class); for (CustomLogModel customLogModel : customLogModels) { System.out.println(customLogModel.getOperationName() + " " + customLogModel.getResourceGroup()); -} ``` #### Handle logs query response @@ -187,14 +197,15 @@ LogsQueryResult / LogsBatchQueryResult ```java +ic void queryBatch() { LogsQueryClient logsQueryClient = new LogsQueryClientBuilder() .credential(new DefaultAzureCredentialBuilder().build()) .buildClient(); LogsBatchQuery logsBatchQuery = new LogsBatchQuery(); -String query1 = logsBatchQuery.addQuery("{workspace-id}", "{query-1}", new TimeInterval(Duration.ofDays(2))); -String query2 = logsBatchQuery.addQuery("{workspace-id}", "{query-2}", new TimeInterval(Duration.ofDays(30))); -String query3 = logsBatchQuery.addQuery("{workspace-id}", "{query-3}", new TimeInterval(Duration.ofDays(10))); +String query1 = logsBatchQuery.addQuery("{workspace-id}", "{query-1}", new QueryTimeInterval(Duration.ofDays(2))); +String query2 = logsBatchQuery.addQuery("{workspace-id}", "{query-2}", new QueryTimeInterval(Duration.ofDays(30))); +String query3 = logsBatchQuery.addQuery("{workspace-id}", "{query-3}", new QueryTimeInterval(Duration.ofDays(10))); LogsBatchQueryResultCollection batchResults = logsQueryClient .queryBatchWithResponse(logsBatchQuery, Context.NONE).getValue(); @@ -210,9 +221,8 @@ for (CustomLogModel customLogModel : customLogModels) { } LogsBatchQueryResult query3Result = batchResults.getResult(query3); -if (query3Result.hasFailed()) { +if (query3Result.getQueryResultStatus() == LogsQueryResultStatus.FAILURE) { System.out.println(query3Result.getError().getMessage()); -} ``` ### Advanced logs query scenarios @@ -221,6 +231,7 @@ if (query3Result.hasFailed()) { ```java +ic void getLogsWithServerTimeout() { LogsQueryClient logsQueryClient = new LogsQueryClientBuilder() .credential(new DefaultAzureCredentialBuilder().build()) .buildClient(); @@ -230,7 +241,6 @@ LogsQueryOptions options = new LogsQueryOptions() .setServerTimeout(Duration.ofMinutes(10)); Response response = logsQueryClient.queryWithResponse("{workspace-id}", - "{kusto-query}", new TimeInterval(Duration.ofDays(2)), options, Context.NONE); ``` #### Query multiple workspaces @@ -244,15 +254,15 @@ to include this column. ```java +ic void getLogsQueryFromMultipleWorkspaces() { LogsQueryClient logsQueryClient = new LogsQueryClientBuilder() .credential(new DefaultAzureCredentialBuilder().build()) .buildClient(); Response response = logsQueryClient.queryWithResponse("{workspace-id}", "{kusto-query}", - new TimeInterval(Duration.ofDays(2)), new LogsQueryOptions() + new QueryTimeInterval(Duration.ofDays(2)), new LogsQueryOptions() .setAdditionalWorkspaces(Arrays.asList("{additional-workspace-identifiers}")), Context.NONE); -LogsQueryResult result = response.getValue(); ``` ### Metrics query @@ -265,6 +275,7 @@ A resource ID, as denoted by the `{resource-id}` placeholder in the sample below ```java +ic void getMetrics() { MetricsQueryClient metricsQueryClient = new MetricsQueryClientBuilder() .credential(new DefaultAzureCredentialBuilder().build()) .buildClient(); @@ -280,7 +291,6 @@ for (MetricResult metric : metricsQueryResult.getMetrics()) { System.out.println(metricValue.getTimeStamp() + " " + metricValue.getTotal()); } } -} ``` #### Handle metrics query response @@ -314,6 +324,7 @@ MetricsQueryResult ```java +ic void getMetricsWithOptions() { MetricsQueryClient metricsQueryClient = new MetricsQueryClientBuilder() .credential(new DefaultAzureCredentialBuilder().build()) .buildClient(); @@ -335,7 +346,6 @@ for (MetricResult metric : metricsQueryResult.getMetrics()) { System.out.println(metricValue.getTimeStamp() + " " + metricValue.getTotal()); } } -} ``` ## Troubleshooting diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/LogsQueryAsyncClient.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/LogsQueryAsyncClient.java index e93143a338fd5..c4a555027134a 100644 --- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/LogsQueryAsyncClient.java +++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/LogsQueryAsyncClient.java @@ -7,8 +7,8 @@ import com.azure.core.annotation.ServiceClient; import com.azure.core.annotation.ServiceMethod; import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ServiceResponseException; import com.azure.core.experimental.models.HttpResponseError; -import com.azure.core.experimental.models.TimeInterval; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.BinaryData; @@ -31,11 +31,14 @@ import com.azure.monitor.query.models.LogsBatchQueryResultCollection; import com.azure.monitor.query.models.LogsQueryOptions; import com.azure.monitor.query.models.LogsQueryResult; +import com.azure.monitor.query.models.LogsQueryResultStatus; import com.azure.monitor.query.models.LogsTable; import com.azure.monitor.query.models.LogsTableCell; import com.azure.monitor.query.models.LogsTableColumn; import com.azure.monitor.query.models.LogsTableRow; +import com.azure.monitor.query.models.QueryTimeInterval; import reactor.core.publisher.Mono; +import reactor.core.publisher.SynchronousSink; import java.time.Duration; import java.util.ArrayList; @@ -69,7 +72,7 @@ public final class LogsQueryAsyncClient { * Returns all the Azure Monitor logs matching the given query in the specified workspaceId. * *

Query logs from the last 24 hours

- * {@codesnippet com.azure.monitor.query.LogsQueryAsyncClient.query#String-String-TimeInterval} + * {@codesnippet com.azure.monitor.query.LogsQueryAsyncClient.query#String-String-QueryTimeInterval} * * @param workspaceId The workspaceId where the query should be executed. * @param query The Kusto query to fetch the logs. @@ -77,7 +80,7 @@ public final class LogsQueryAsyncClient { * @return The logs matching the query. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono query(String workspaceId, String query, TimeInterval timeInterval) { + public Mono query(String workspaceId, String query, QueryTimeInterval timeInterval) { return queryWithResponse(workspaceId, query, timeInterval, new LogsQueryOptions()) .map(Response::getValue); } @@ -92,7 +95,7 @@ public Mono query(String workspaceId, String query, TimeInterva * @return The logs matching the query as a list of objects of type T. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> query(String workspaceId, String query, TimeInterval timeInterval, Class type) { + public Mono> query(String workspaceId, String query, QueryTimeInterval timeInterval, Class type) { return query(workspaceId, query, timeInterval) .map(result -> LogsQueryHelper.toObject(result.getTable(), type)); } @@ -108,7 +111,7 @@ public Mono> query(String workspaceId, String query, TimeInterval ti * @return The logs matching the query as a list of objects of type T. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> query(String workspaceId, String query, TimeInterval timeInterval, + public Mono> query(String workspaceId, String query, QueryTimeInterval timeInterval, Class type, LogsQueryOptions options) { return queryWithResponse(workspaceId, query, timeInterval, options, Context.NONE) .map(response -> LogsQueryHelper.toObject(response.getValue().getTable(), type)); @@ -119,7 +122,7 @@ public Mono> query(String workspaceId, String query, TimeInterval ti * *

Query logs from the last 7 days and set the service timeout to 2 minutes

* - * {@codesnippet com.azure.monitor.query.LogsQueryAsyncClient.queryWithResponse#String-String-TimeInterval-LogsQueryOptions} + * {@codesnippet com.azure.monitor.query.LogsQueryAsyncClient.queryWithResponse#String-String-QueryTimeInterval-LogsQueryOptions} * * @param workspaceId The workspaceId where the query should be executed. * @param query The Kusto query to fetch the logs. @@ -130,7 +133,7 @@ public Mono> query(String workspaceId, String query, TimeInterval ti */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> queryWithResponse(String workspaceId, String query, - TimeInterval timeInterval, LogsQueryOptions options) { + QueryTimeInterval timeInterval, LogsQueryOptions options) { return withContext(context -> queryWithResponse(workspaceId, query, timeInterval, options, context)); } @@ -147,7 +150,7 @@ public Mono> queryWithResponse(String workspaceId, Str * @return The logs matching the query including the HTTP response. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono>> queryWithResponse(String workspaceId, String query, TimeInterval timeInterval, + public Mono>> queryWithResponse(String workspaceId, String query, QueryTimeInterval timeInterval, Class type, LogsQueryOptions options) { return queryWithResponse(workspaceId, query, timeInterval, options) .map(response -> new SimpleResponse<>(response.getRequest(), @@ -164,7 +167,7 @@ public Mono>> queryWithResponse(String workspaceId, String * @return A collection of query results corresponding to the input batch of queries. */ Mono queryBatch(String workspaceId, List queries, - TimeInterval timeInterval) { + QueryTimeInterval timeInterval) { LogsBatchQuery logsBatchQuery = new LogsBatchQuery(); queries.forEach(query -> logsBatchQuery.addQuery(workspaceId, query, timeInterval)); return queryBatchWithResponse(logsBatchQuery).map(Response::getValue); @@ -263,14 +266,14 @@ private HttpResponseError mapLogsQueryError(ErrorInfo errors) { return null; } - Mono> queryWithResponse(String workspaceId, String query, TimeInterval timeInterval, + Mono> queryWithResponse(String workspaceId, String query, QueryTimeInterval timeInterval, LogsQueryOptions options, Context context) { String preferHeader = LogsQueryHelper.buildPreferHeaderString(options); context = updateContext(options.getServerTimeout(), context); QueryBody queryBody = new QueryBody(query); if (timeInterval != null) { - queryBody.setTimespan(timeInterval.toIso8601Format()); + queryBody.setTimespan(LogsQueryHelper.toIso8601Format(timeInterval)); } queryBody.setWorkspaces(getAllWorkspaces(options)); return innerClient @@ -288,7 +291,16 @@ Mono> queryWithResponse(String workspaceId, String que } return ex; }) - .map(this::convertToLogQueryResult); + .map(this::convertToLogQueryResult) + .handle((Response response, SynchronousSink> sink) -> { + if (response.getValue().getQueryResultStatus() == LogsQueryResultStatus.PARTIAL_FAILURE) { + sink.error(new ServiceResponseException("Query execution returned partial errors. To " + + "disable exceptions on partial errors, set disableExceptionOnPartialErrors in " + + "LogsQueryOptions to true.")); + } else { + sink.next(response); + } + }); } private Response convertToLogQueryResult(Response response) { diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/LogsQueryClient.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/LogsQueryClient.java index c70aec420ce4d..5497ed5467c24 100644 --- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/LogsQueryClient.java +++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/LogsQueryClient.java @@ -6,7 +6,6 @@ import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; import com.azure.core.annotation.ServiceMethod; -import com.azure.core.experimental.models.TimeInterval; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; @@ -15,6 +14,7 @@ import com.azure.monitor.query.models.LogsBatchQueryResultCollection; import com.azure.monitor.query.models.LogsQueryOptions; import com.azure.monitor.query.models.LogsQueryResult; +import com.azure.monitor.query.models.QueryTimeInterval; import java.util.List; @@ -43,14 +43,14 @@ public final class LogsQueryClient { * *

Query logs from the last 24 hours

* - * {@codesnippet com.azure.monitor.query.LogsQueryClient.query#String-String-TimeInterval} + * {@codesnippet com.azure.monitor.query.LogsQueryClient.query#String-String-QueryTimeInterval} * @param workspaceId The workspaceId where the query should be executed. * @param query The Kusto query to fetch the logs. * @param timeInterval The time period for which the logs should be looked up. * @return The logs matching the query. */ @ServiceMethod(returns = ReturnType.SINGLE) - public LogsQueryResult query(String workspaceId, String query, TimeInterval timeInterval) { + public LogsQueryResult query(String workspaceId, String query, QueryTimeInterval timeInterval) { return asyncClient.query(workspaceId, query, timeInterval).block(); } @@ -64,7 +64,7 @@ public LogsQueryResult query(String workspaceId, String query, TimeInterval time * @return The logs matching the query as a list of objects of type T. */ @ServiceMethod(returns = ReturnType.SINGLE) - public List query(String workspaceId, String query, TimeInterval timeInterval, Class type) { + public List query(String workspaceId, String query, QueryTimeInterval timeInterval, Class type) { LogsQueryResult logsQueryResult = asyncClient.query(workspaceId, query, timeInterval).block(); if (logsQueryResult != null) { return LogsQueryHelper.toObject(logsQueryResult.getTable(), type); @@ -84,7 +84,7 @@ public List query(String workspaceId, String query, TimeInterval timeInte * @return The logs matching the query as a list of objects of type T. */ @ServiceMethod(returns = ReturnType.SINGLE) - public List query(String workspaceId, String query, TimeInterval timeInterval, + public List query(String workspaceId, String query, QueryTimeInterval timeInterval, Class type, LogsQueryOptions options) { LogsQueryResult logsQueryResult = queryWithResponse(workspaceId, query, timeInterval, options, Context.NONE) .getValue(); @@ -99,7 +99,7 @@ public List query(String workspaceId, String query, TimeInterval timeInte * *

Query logs from the last 7 days and set the service timeout to 2 minutes

* - * {@codesnippet com.azure.monitor.query.LogsQueryClient.queryWithResponse#String-String-TimeInterval-LogsQueryOptions-Context} + * {@codesnippet com.azure.monitor.query.LogsQueryClient.queryWithResponse#String-String-QueryTimeInterval-LogsQueryOptions-Context} * @param workspaceId The workspaceId where the query should be executed. * @param query The Kusto query to fetch the logs. * @param timeInterval The time period for which the logs should be looked up. @@ -110,7 +110,7 @@ public List query(String workspaceId, String query, TimeInterval timeInte * @return The logs matching the query including the HTTP response. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response queryWithResponse(String workspaceId, String query, TimeInterval timeInterval, + public Response queryWithResponse(String workspaceId, String query, QueryTimeInterval timeInterval, LogsQueryOptions options, Context context) { return asyncClient.queryWithResponse(workspaceId, query, timeInterval, options, context).block(); } @@ -130,7 +130,7 @@ public Response queryWithResponse(String workspaceId, String qu * @return The logs matching the query including the HTTP response. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response> queryWithResponse(String workspaceId, String query, TimeInterval timeInterval, + public Response> queryWithResponse(String workspaceId, String query, QueryTimeInterval timeInterval, Class type, LogsQueryOptions options, Context context) { return asyncClient.queryWithResponse(workspaceId, query, timeInterval, options, context) .map(response -> new SimpleResponse<>(response.getRequest(), @@ -146,7 +146,7 @@ public Response> queryWithResponse(String workspaceId, String query, * @param timeInterval The time period for which the logs should be looked up. * @return A collection of query results corresponding to the input batch of queries. */ - LogsBatchQueryResultCollection queryBatch(String workspaceId, List queries, TimeInterval timeInterval) { + LogsBatchQueryResultCollection queryBatch(String workspaceId, List queries, QueryTimeInterval timeInterval) { return asyncClient.queryBatch(workspaceId, queries, timeInterval).block(); } diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/MetricsQueryAsyncClient.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/MetricsQueryAsyncClient.java index fe394e56d763a..e31f66a095bc8 100644 --- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/MetricsQueryAsyncClient.java +++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/MetricsQueryAsyncClient.java @@ -7,12 +7,12 @@ import com.azure.core.annotation.ServiceClient; import com.azure.core.annotation.ServiceMethod; import com.azure.core.experimental.models.HttpResponseError; -import com.azure.core.experimental.models.TimeInterval; import com.azure.core.http.rest.PagedFlux; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; import com.azure.core.util.CoreUtils; +import com.azure.monitor.query.implementation.logs.models.LogsQueryHelper; import com.azure.monitor.query.implementation.metrics.models.Metric; import com.azure.monitor.query.implementation.metrics.MonitorManagementClientImpl; import com.azure.monitor.query.implementation.metrics.models.MetadataValue; @@ -28,6 +28,7 @@ import com.azure.monitor.query.models.MetricNamespace; import com.azure.monitor.query.models.MetricsQueryOptions; import com.azure.monitor.query.models.MetricsQueryResult; +import com.azure.monitor.query.models.QueryTimeInterval; import com.azure.monitor.query.models.TimeSeriesElement; import com.azure.monitor.query.models.MetricValue; import reactor.core.publisher.Mono; @@ -189,7 +190,8 @@ Mono> queryWithResponse(String resourceUri, List String.valueOf(type.ordinal())) .collect(Collectors.joining(",")); } - String timespan = options.getTimeInterval() == null ? null : options.getTimeInterval().toIso8601Format(); + String timespan = options.getTimeInterval() == null ? null + : LogsQueryHelper.toIso8601Format(options.getTimeInterval()); return metricsClient .getMetrics() .listWithResponseAsync(resourceUri, timespan, options.getGranularity(), @@ -202,7 +204,7 @@ private Response convertToMetricsQueryResult(Response List toObject(LogsTable table, Class type) { } return result; } + + /** + * Returns this {@link com.azure.core.experimental.models.TimeInterval} in ISO 8601 string format. + * + * @return ISO 8601 formatted string representation of this {@link com.azure.core.experimental.models.TimeInterval} instance. + */ + public static String toIso8601Format(QueryTimeInterval timeInterval) { + if (timeInterval.getStartTime() != null && timeInterval.getEndTime() != null) { + return timeInterval.getStartTime() + "/" + timeInterval.getEndTime(); + } + + if (timeInterval.getStartTime() != null && timeInterval.getDuration() != null) { + return timeInterval.getStartTime() + "/" + timeInterval.getDuration(); + } + + if (timeInterval.getDuration()!= null && timeInterval.getEndTime() != null) { + return timeInterval.getDuration() + "/" + timeInterval.getEndTime(); + } + + return timeInterval.getDuration() == null ? null : timeInterval.getDuration().toString(); + } } diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsBatchQuery.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsBatchQuery.java index a5ed395108b87..abe8d084f4475 100644 --- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsBatchQuery.java +++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsBatchQuery.java @@ -4,7 +4,6 @@ package com.azure.monitor.query.models; import com.azure.core.annotation.Fluent; -import com.azure.core.experimental.models.TimeInterval; import com.azure.core.util.CoreUtils; import com.azure.monitor.query.implementation.logs.models.LogsQueryHelper; import com.azure.monitor.query.implementation.logs.models.BatchQueryRequest; @@ -49,7 +48,7 @@ public Duration getMaxServerTimeout(LogsBatchQuery query) { * @param timeInterval The time period for which the logs should be queried. * @return The index of the query in the batch. */ - public String addQuery(String workspaceId, String query, TimeInterval timeInterval) { + public String addQuery(String workspaceId, String query, QueryTimeInterval timeInterval) { return addQuery(workspaceId, query, timeInterval, new LogsQueryOptions()); } @@ -62,14 +61,14 @@ public String addQuery(String workspaceId, String query, TimeInterval timeInterv * statistics and rendering information in response. * @return The index of the query in the batch. */ - public String addQuery(String workspaceId, String query, TimeInterval timeInterval, + public String addQuery(String workspaceId, String query, QueryTimeInterval timeInterval, LogsQueryOptions logsQueryOptions) { Objects.requireNonNull(query, "'query' cannot be null."); Objects.requireNonNull(workspaceId, "'workspaceId' cannot be null."); index++; QueryBody queryBody = new QueryBody(query) .setWorkspaces(logsQueryOptions == null ? null : logsQueryOptions.getAdditionalWorkspaces()) - .setTimespan(timeInterval == null ? null : timeInterval.toIso8601Format()); + .setTimespan(timeInterval == null ? null : LogsQueryHelper.toIso8601Format(timeInterval)); String preferHeader = buildPreferHeaderString(logsQueryOptions); if (logsQueryOptions != null && logsQueryOptions.getServerTimeout() != null) { diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsBatchQueryResult.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsBatchQueryResult.java index 9d541280955c6..95ea4e724a683 100644 --- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsBatchQueryResult.java +++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsBatchQueryResult.java @@ -6,7 +6,6 @@ import com.azure.core.annotation.Immutable; import com.azure.core.experimental.models.HttpResponseError; import com.azure.core.util.BinaryData; -import com.azure.core.util.CoreUtils; import java.util.List; @@ -46,21 +45,8 @@ public String getId() { * Returns the response status of the query. * @return The response status of the query. */ - public int getStatus() { + int getStatus() { return status; } - - /** - * Returns true if the query failed. If the query partially succeeded i.e. there are tables returned in the - * response, then this method will return {@code false}. - * - * @return Returns true if the query failed. - */ - public boolean hasFailed() { - if (getError() != null && CoreUtils.isNullOrEmpty(getAllTables())) { - return true; - } - return false; - } } diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryOptions.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryOptions.java index effab6ecc59a4..fe1487c452d19 100644 --- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryOptions.java +++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryOptions.java @@ -16,6 +16,7 @@ public final class LogsQueryOptions { private boolean includeVisualization; private boolean includeStatistics; + private boolean allowPartialErrors; private Duration serverTimeout; private List additionalWorkspaces; @@ -73,6 +74,27 @@ public LogsQueryOptions setIncludeStatistics(boolean includeStatistics) { return this; } + /** + * If a query has partial errors, the result is returned instead of throwing an exception if this is set to true. + * The partial error information is available as part of the query result. + * + * @return Returns true if partial errors should not throw exception. + */ + public boolean isAllowPartialErrors() { + return allowPartialErrors; + } + + /** + * If set to {@code true}, exception is not thrown if query returns partial errors. The partial error information + * is available as part of the query result. + * @param allowPartialErrors set this to {@code true} to not throw exception if a query returns partial errors. + * @return The updated options instance. + */ + public LogsQueryOptions setAllowPartialErrors(boolean allowPartialErrors) { + this.allowPartialErrors = allowPartialErrors; + return this; + } + /** * Returns the list of additional workspaces on which this query is executed. The list can contain any of the * following workspace identifiers: diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryResult.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryResult.java index f3d71ccf1acb6..1fb2e2e222190 100644 --- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryResult.java +++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryResult.java @@ -6,6 +6,7 @@ import com.azure.core.annotation.Immutable; import com.azure.core.experimental.models.HttpResponseError; import com.azure.core.util.BinaryData; +import com.azure.core.util.CoreUtils; import com.azure.core.util.logging.ClientLogger; import java.util.List; @@ -20,6 +21,7 @@ public class LogsQueryResult { private final BinaryData statistics; private final HttpResponseError error; private final BinaryData visualization; + private final LogsQueryResultStatus queryResultStatus; private final ClientLogger logger = new ClientLogger(LogsQueryResult.class); /** @@ -35,6 +37,14 @@ public LogsQueryResult(List logsTables, BinaryData statistics, this.statistics = statistics; this.error = error; this.visualization = visualization; + + if (CoreUtils.isNullOrEmpty(logsTables) && error != null) { + queryResultStatus = LogsQueryResultStatus.FAILURE; + } else if (!CoreUtils.isNullOrEmpty(logsTables) && error != null) { + queryResultStatus = LogsQueryResultStatus.PARTIAL_FAILURE; + } else { + queryResultStatus = LogsQueryResultStatus.SUCCESS; + } } /** @@ -107,4 +117,12 @@ public HttpResponseError getError() { public BinaryData getVisualization() { return visualization; } + + /** + * Returns the status of the query result. + * @return the status of the query result. + */ + public LogsQueryResultStatus getQueryResultStatus() { + return queryResultStatus; + } } diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryResultStatus.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryResultStatus.java new file mode 100644 index 0000000000000..4468c70b17f71 --- /dev/null +++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryResultStatus.java @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.monitor.query.models; + +/** + * Enum to indicate the status of a logs query result. + */ +public enum LogsQueryResultStatus { + SUCCESS, + FAILURE, + PARTIAL_FAILURE; +} diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricsQueryOptions.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricsQueryOptions.java index e0ada07f33137..57d6eed361949 100644 --- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricsQueryOptions.java +++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricsQueryOptions.java @@ -4,7 +4,6 @@ package com.azure.monitor.query.models; import com.azure.core.annotation.Fluent; -import com.azure.core.experimental.models.TimeInterval; import java.time.Duration; import java.util.Arrays; @@ -15,7 +14,7 @@ */ @Fluent public final class MetricsQueryOptions { - private TimeInterval timeInterval; + private QueryTimeInterval timeInterval; private Duration granularity; private List aggregations; private Integer top; @@ -27,7 +26,7 @@ public final class MetricsQueryOptions { * Returns the time span for which the metrics data is queried. * @return the time span for which the metrics data is queried. */ - public TimeInterval getTimeInterval() { + public QueryTimeInterval getTimeInterval() { return timeInterval; } @@ -37,7 +36,7 @@ public TimeInterval getTimeInterval() { * * @return The updated options instance */ - public MetricsQueryOptions setTimeInterval(TimeInterval timeInterval) { + public MetricsQueryOptions setTimeInterval(QueryTimeInterval timeInterval) { this.timeInterval = timeInterval; return this; } diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricsQueryResult.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricsQueryResult.java index ab393012fcb0d..c994a2a0a9917 100644 --- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricsQueryResult.java +++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricsQueryResult.java @@ -4,7 +4,6 @@ package com.azure.monitor.query.models; import com.azure.core.annotation.Immutable; -import com.azure.core.experimental.models.TimeInterval; import com.azure.core.util.CoreUtils; import java.time.Duration; @@ -18,7 +17,7 @@ public final class MetricsQueryResult { private final Integer cost; - private final TimeInterval timeInterval; + private final QueryTimeInterval timeInterval; private final Duration granularity; private final String namespace; private final String resourceRegion; @@ -33,7 +32,7 @@ public final class MetricsQueryResult { * @param resourceRegion the region of the resource been queried for metrics. * @param metrics the value of the collection. */ - public MetricsQueryResult(Integer cost, TimeInterval timeInterval, Duration granularity, String namespace, + public MetricsQueryResult(Integer cost, QueryTimeInterval timeInterval, Duration granularity, String namespace, String resourceRegion, List metrics) { this.cost = cost; this.timeInterval = timeInterval; @@ -55,7 +54,7 @@ public Integer getCost() { * Returns the time interval for which the data was retrieved. * @return the time interval for which the data was retrieved. */ - public TimeInterval getTimeInterval() { + public QueryTimeInterval getTimeInterval() { return timeInterval; } diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/QueryTimeInterval.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/QueryTimeInterval.java new file mode 100644 index 0000000000000..90e4405e4cd33 --- /dev/null +++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/QueryTimeInterval.java @@ -0,0 +1,239 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.monitor.query.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; + +import java.time.Duration; +import java.time.OffsetDateTime; +import java.util.Objects; + +/** + * Class to represent a time interval. + */ +@Immutable +public final class QueryTimeInterval { + public static final QueryTimeInterval ALL = new QueryTimeInterval(OffsetDateTime.MIN, OffsetDateTime.MAX); + + public static final QueryTimeInterval LAST_5_MINUTES = new QueryTimeInterval(Duration.ofMinutes(5)); + public static final QueryTimeInterval LAST_30_MINUTES = new QueryTimeInterval(Duration.ofMinutes(30)); + + public static final QueryTimeInterval LAST_1_HOUR = new QueryTimeInterval(Duration.ofHours(1)); + public static final QueryTimeInterval LAST_4_HOURS = new QueryTimeInterval(Duration.ofHours(4)); + public static final QueryTimeInterval LAST_12_HOURS = new QueryTimeInterval(Duration.ofHours(12)); + + public static final QueryTimeInterval LAST_DAY = new QueryTimeInterval(Duration.ofDays(1)); + public static final QueryTimeInterval LAST_2_DAYS = new QueryTimeInterval(Duration.ofDays(2)); + public static final QueryTimeInterval LAST_3_DAYS = new QueryTimeInterval(Duration.ofDays(3)); + public static final QueryTimeInterval LAST_7_DAYS = new QueryTimeInterval(Duration.ofDays(7)); + + private static final ClientLogger LOGGER = new ClientLogger(QueryTimeInterval.class); + private static final String ERROR_MESSAGE = "%s is an invalid time interval. It must be in one of the " + + "following ISO 8601 time interval formats: duration, startDuration/endTime, " + + "startTime/endTime, startTime/endDuration"; + + private final Duration duration; + private final OffsetDateTime startTime; + private final OffsetDateTime endTime; + + /** + * Creates an instance of {@link QueryTimeInterval} using the provided duration. The duration is the interval that starts + * from the provided duration and ends at the current time. + * + * @param duration the duration for this query time span. + */ + public QueryTimeInterval(Duration duration) { + this.duration = Objects.requireNonNull(duration, "'duration' cannot be null"); + this.startTime = null; + this.endTime = null; + } + + /** + * Creates an instance of {@link QueryTimeInterval} using the start and end {@link OffsetDateTime OffsetDateTimes}. + * + * @param startTime The start time of the interval. + * @param endTime The end time of the interval. + */ + public QueryTimeInterval(OffsetDateTime startTime, OffsetDateTime endTime) { + this.startTime = Objects.requireNonNull(startTime, "'startTime' cannot be null"); + this.endTime = Objects.requireNonNull(endTime, "'endTime' cannot be null"); + this.duration = null; + } + + /** + * Creates an instance of {@link QueryTimeInterval} using the start and end duration of the interval. + * + * @param startTime The start time of the interval. + * @param duration The end duration of the interval. + */ + public QueryTimeInterval(OffsetDateTime startTime, Duration duration) { + this.startTime = Objects.requireNonNull(startTime, "'startTime' cannot be null"); + this.duration = Objects.requireNonNull(duration, "'duration' cannot be null"); + this.endTime = null; + } + + /** + * Creates an instance of {@link QueryTimeInterval} using the start and end duration of the interval. + * + * @param duration The duration of the interval. + * @param endTime The end time of the interval. + */ + QueryTimeInterval(Duration duration, OffsetDateTime endTime) { + this.endTime = Objects.requireNonNull(endTime, "'endTime' cannot be null"); + this.duration = Objects.requireNonNull(duration, "'duration' cannot be null"); + this.startTime = null; + } + + /** + * Returns the duration of this {@link QueryTimeInterval} instance. + * + * @return the duration of this {@link QueryTimeInterval} instance. + */ + public Duration getDuration() { + return duration; + } + + /** + * Returns the start time of this {@link QueryTimeInterval} instance. + * + * @return the start time of this {@link QueryTimeInterval} instance. + */ + public OffsetDateTime getStartTime() { + if (startTime != null) { + return startTime; + } + // This check is not required as the constructor would not allow duration and endtime to be null if + // startTime is null. But spotbugs raises an error for not checking null here. + if (duration != null && endTime != null) { + return endTime.minusNanos(duration.toNanos()); + } + return null; + } + + /** + * Returns the end time of this {@link QueryTimeInterval} instance. + * + * @return the end time of this {@link QueryTimeInterval} instance. + */ + public OffsetDateTime getEndTime() { + if (endTime != null) { + return endTime; + } + if (startTime != null && duration != null) { + return startTime.plusNanos(duration.toNanos()); + } + return null; + } + + /** + * This method takes an ISO 8601 formatted time interval string and returns an instance of {@link QueryTimeInterval}. + * + * @param value The ISO 8601 formatted time interval string. + * @return An instance of {@link QueryTimeInterval}. + * @throws IllegalArgumentException if {@code value} is not in the correct format. + */ + public static QueryTimeInterval parse(String value) { + Objects.requireNonNull(value); + + String[] parts = value.split("/"); + if (parts.length == 1) { + // duration + Duration duration = parseDuration(parts[0]); + if (duration == null || parts[0].length() + 1 == value.length()) { + // input strings like "PT24H/" are invalid + throw LOGGER.logExceptionAsError( + new IllegalArgumentException(String.format(ERROR_MESSAGE, value))); + } + + return new QueryTimeInterval(duration); + } + + if (parts.length == 2) { + Duration startDuration = parseDuration(parts[0]); + OffsetDateTime startTime = parseTime(parts[0]); + + Duration endDuration = parseDuration(parts[1]); + OffsetDateTime endTime = parseTime(parts[1]); + + if (startDuration != null && endTime != null) { + return new QueryTimeInterval(startDuration, endTime); + } + if (startTime != null && endTime != null) { + return new QueryTimeInterval(startTime, endTime); + } + if (startTime != null && endDuration != null) { + return new QueryTimeInterval(startTime, endDuration); + } + } + throw LOGGER.logExceptionAsError( + new IllegalArgumentException(String.format(ERROR_MESSAGE, value))); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("["); + if (duration != null && endTime != null) { + sb.append("duration: ") + .append(duration) + .append(", ") + .append("end time: ") + .append(endTime); + } else if (startTime != null && endTime != null) { + sb.append("start time: ") + .append(startTime) + .append(", ") + .append("end time: ") + .append(endTime); + } else if (startTime != null && duration != null) { + sb.append("start time: ") + .append(startTime) + .append(", ") + .append("duration: ") + .append(duration); + } else { + sb.append("duration: ").append(duration); + } + sb.append("]"); + return sb.toString(); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + QueryTimeInterval that = (QueryTimeInterval) o; + + return Objects.equals(this.duration, that.duration) + && Objects.equals(this.startTime, that.startTime) + && Objects.equals(this.endTime, that.endTime); + } + + @Override + public int hashCode() { + return Objects.hash(duration, startTime, endTime); + } + + private static OffsetDateTime parseTime(String value) { + try { + return OffsetDateTime.parse(value); + } catch (Exception exception) { + return null; + } + } + + private static Duration parseDuration(String value) { + try { + return Duration.parse(value); + } catch (Exception exception) { + return null; + } + } +} diff --git a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/LogsQueryWithModels.java b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/LogsQueryWithModels.java index f192713b878ae..b6ccb87c7ad62 100644 --- a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/LogsQueryWithModels.java +++ b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/LogsQueryWithModels.java @@ -3,10 +3,10 @@ package com.azure.monitor.query; -import com.azure.core.experimental.models.TimeInterval; import com.azure.core.util.Configuration; import com.azure.identity.ClientSecretCredential; import com.azure.identity.ClientSecretCredentialBuilder; +import com.azure.monitor.query.models.QueryTimeInterval; import java.util.List; @@ -32,7 +32,7 @@ public static void main(String[] args) { // Sample to use a model type to read the results List customModels = logsQueryClient - .query("{workspace-id}", "AppRequests", TimeInterval.ALL, CustomModel.class); + .query("{workspace-id}", "AppRequests", QueryTimeInterval.ALL, CustomModel.class); customModels.forEach(model -> System.out.println("Time generated " + model.getTimeGenerated() + "; success = " + model.getSuccess() + "; operation name = " + model.getOperationName())); diff --git a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/MetricsQuerySample.java b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/MetricsQuerySample.java index 54ef828cde5d0..1c2576040c1ee 100644 --- a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/MetricsQuerySample.java +++ b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/MetricsQuerySample.java @@ -3,7 +3,6 @@ package com.azure.monitor.query; -import com.azure.core.experimental.models.TimeInterval; import com.azure.core.http.rest.Response; import com.azure.core.util.Configuration; import com.azure.core.util.Context; @@ -13,6 +12,7 @@ import com.azure.monitor.query.models.MetricResult; import com.azure.monitor.query.models.MetricsQueryOptions; import com.azure.monitor.query.models.MetricsQueryResult; +import com.azure.monitor.query.models.QueryTimeInterval; import java.time.Duration; import java.util.Arrays; @@ -45,7 +45,7 @@ public static void main(String[] args) { Arrays.asList("SuccessfulCalls"), new MetricsQueryOptions() .setMetricNamespace("Microsoft.CognitiveServices/accounts") - .setTimeInterval(new TimeInterval(Duration.ofDays(30))) + .setTimeInterval(new QueryTimeInterval(Duration.ofDays(30))) .setGranularity(Duration.ofHours(1)) .setTop(100) .setAggregations(Arrays.asList(AggregationType.AVERAGE, AggregationType.COUNT)), diff --git a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/ReadmeSamples.java b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/ReadmeSamples.java index 3c98082e601cb..6d047edcb4fe0 100644 --- a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/ReadmeSamples.java +++ b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/ReadmeSamples.java @@ -3,7 +3,6 @@ package com.azure.monitor.query; -import com.azure.core.experimental.models.TimeInterval; import com.azure.core.http.rest.Response; import com.azure.core.util.Context; import com.azure.identity.DefaultAzureCredentialBuilder; @@ -13,11 +12,13 @@ import com.azure.monitor.query.models.LogsBatchQueryResultCollection; import com.azure.monitor.query.models.LogsQueryOptions; import com.azure.monitor.query.models.LogsQueryResult; +import com.azure.monitor.query.models.LogsQueryResultStatus; import com.azure.monitor.query.models.LogsTableRow; import com.azure.monitor.query.models.MetricResult; import com.azure.monitor.query.models.MetricValue; import com.azure.monitor.query.models.MetricsQueryOptions; import com.azure.monitor.query.models.MetricsQueryResult; +import com.azure.monitor.query.models.QueryTimeInterval; import com.azure.monitor.query.models.TimeSeriesElement; import java.time.Duration; @@ -67,7 +68,7 @@ public void queryLogs() { .buildClient(); LogsQueryResult queryResults = logsQueryClient.query("{workspace-id}", "{kusto-query}", - new TimeInterval(Duration.ofDays(2))); + new QueryTimeInterval(Duration.ofDays(2))); for (LogsTableRow row : queryResults.getTable().getRows()) { System.out.println(row.getColumnValue("OperationName") + " " + row.getColumnValue("ResourceGroup")); @@ -99,7 +100,7 @@ public void queryLogsAsModel() { .buildClient(); List customLogModels = logsQueryClient.query("{workspace-id}", "{kusto-query}", - new TimeInterval(Duration.ofDays(2)), CustomLogModel.class); + new QueryTimeInterval(Duration.ofDays(2)), CustomLogModel.class); for (CustomLogModel customLogModel : customLogModels) { System.out.println(customLogModel.getOperationName() + " " + customLogModel.getResourceGroup()); @@ -115,9 +116,9 @@ public void queryBatch() { .buildClient(); LogsBatchQuery logsBatchQuery = new LogsBatchQuery(); - String query1 = logsBatchQuery.addQuery("{workspace-id}", "{query-1}", new TimeInterval(Duration.ofDays(2))); - String query2 = logsBatchQuery.addQuery("{workspace-id}", "{query-2}", new TimeInterval(Duration.ofDays(30))); - String query3 = logsBatchQuery.addQuery("{workspace-id}", "{query-3}", new TimeInterval(Duration.ofDays(10))); + String query1 = logsBatchQuery.addQuery("{workspace-id}", "{query-1}", new QueryTimeInterval(Duration.ofDays(2))); + String query2 = logsBatchQuery.addQuery("{workspace-id}", "{query-2}", new QueryTimeInterval(Duration.ofDays(30))); + String query3 = logsBatchQuery.addQuery("{workspace-id}", "{query-3}", new QueryTimeInterval(Duration.ofDays(10))); LogsBatchQueryResultCollection batchResults = logsQueryClient .queryBatchWithResponse(logsBatchQuery, Context.NONE).getValue(); @@ -133,7 +134,7 @@ public void queryBatch() { } LogsBatchQueryResult query3Result = batchResults.getResult(query3); - if (query3Result.hasFailed()) { + if (query3Result.getQueryResultStatus() == LogsQueryResultStatus.FAILURE) { System.out.println(query3Result.getError().getMessage()); } } @@ -152,7 +153,7 @@ public void getLogsWithServerTimeout() { .setServerTimeout(Duration.ofMinutes(10)); Response response = logsQueryClient.queryWithResponse("{workspace-id}", - "{kusto-query}", new TimeInterval(Duration.ofDays(2)), options, Context.NONE); + "{kusto-query}", new QueryTimeInterval(Duration.ofDays(2)), options, Context.NONE); } /** @@ -164,7 +165,7 @@ public void getLogsQueryFromMultipleWorkspaces() { .buildClient(); Response response = logsQueryClient.queryWithResponse("{workspace-id}", "{kusto-query}", - new TimeInterval(Duration.ofDays(2)), new LogsQueryOptions() + new QueryTimeInterval(Duration.ofDays(2)), new LogsQueryOptions() .setAdditionalWorkspaces(Arrays.asList("{additional-workspace-identifiers}")), Context.NONE); LogsQueryResult result = response.getValue(); diff --git a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/codesnippets/LogsQueryClientJavaDocCodeSnippets.java b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/codesnippets/LogsQueryClientJavaDocCodeSnippets.java index 1fb34d5300cbc..084ea07e4cb07 100644 --- a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/codesnippets/LogsQueryClientJavaDocCodeSnippets.java +++ b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/codesnippets/LogsQueryClientJavaDocCodeSnippets.java @@ -4,7 +4,6 @@ package com.azure.monitor.query.codesnippets; import com.azure.core.credential.TokenCredential; -import com.azure.core.experimental.models.TimeInterval; import com.azure.core.http.rest.Response; import com.azure.core.util.Context; import com.azure.identity.DefaultAzureCredentialBuilder; @@ -18,6 +17,7 @@ import com.azure.monitor.query.models.LogsQueryResult; import com.azure.monitor.query.models.LogsTableCell; import com.azure.monitor.query.models.LogsTableRow; +import com.azure.monitor.query.models.QueryTimeInterval; import reactor.core.publisher.Mono; import java.time.Duration; @@ -50,9 +50,9 @@ public void singleQueryAsync() { LogsQueryAsyncClient logsQueryAsyncClient = new LogsQueryClientBuilder() .credential(new DefaultAzureCredentialBuilder().build()) .buildAsyncClient(); - // BEGIN: com.azure.monitor.query.LogsQueryAsyncClient.query#String-String-TimeInterval + // BEGIN: com.azure.monitor.query.LogsQueryAsyncClient.query#String-String-QueryTimeInterval Mono queryResult = logsQueryAsyncClient.query("{workspace-id}", "{kusto-query}", - TimeInterval.LAST_DAY); + QueryTimeInterval.LAST_DAY); queryResult.subscribe(result -> { for (LogsTableRow row : result.getTable().getRows()) { System.out.println(row.getRow() @@ -61,7 +61,7 @@ public void singleQueryAsync() { .collect(Collectors.joining(","))); } }); - // END: com.azure.monitor.query.LogsQueryAsyncClient.query#String-String-TimeInterval + // END: com.azure.monitor.query.LogsQueryAsyncClient.query#String-String-QueryTimeInterval } public void singleQuery() { @@ -69,25 +69,26 @@ public void singleQuery() { .credential(new DefaultAzureCredentialBuilder().build()) .buildClient(); - // BEGIN: com.azure.monitor.query.LogsQueryClient.query#String-String-TimeInterval - LogsQueryResult queryResult = logsQueryClient.query("{workspace-id}", "{kusto-query}", TimeInterval.LAST_DAY); + // BEGIN: com.azure.monitor.query.LogsQueryClient.query#String-String-QueryTimeInterval + LogsQueryResult queryResult = logsQueryClient.query("{workspace-id}", "{kusto-query}", + QueryTimeInterval.LAST_DAY); for (LogsTableRow row : queryResult.getTable().getRows()) { System.out.println(row.getRow() .stream() .map(LogsTableCell::getValueAsString) .collect(Collectors.joining(","))); } - // END: com.azure.monitor.query.LogsQueryClient.query#String-String-TimeInterval + // END: com.azure.monitor.query.LogsQueryClient.query#String-String-QueryTimeInterval } public void singleQueryWithResponseAsync() { LogsQueryAsyncClient logsQueryAsyncClient = new LogsQueryClientBuilder() .credential(new DefaultAzureCredentialBuilder().build()) .buildAsyncClient(); - // BEGIN: com.azure.monitor.query.LogsQueryAsyncClient.queryWithResponse#String-String-TimeInterval-LogsQueryOptions + // BEGIN: com.azure.monitor.query.LogsQueryAsyncClient.queryWithResponse#String-String-QueryTimeInterval-LogsQueryOptions Mono> queryResult = logsQueryAsyncClient.queryWithResponse("{workspace-id}", "{kusto-query}", - TimeInterval.LAST_7_DAYS, + QueryTimeInterval.LAST_7_DAYS, new LogsQueryOptions().setServerTimeout(Duration.ofMinutes(2))); queryResult.subscribe(result -> { @@ -98,7 +99,7 @@ public void singleQueryWithResponseAsync() { .collect(Collectors.joining(","))); } }); - // END: com.azure.monitor.query.LogsQueryAsyncClient.queryWithResponse#String-String-TimeInterval-LogsQueryOptions + // END: com.azure.monitor.query.LogsQueryAsyncClient.queryWithResponse#String-String-QueryTimeInterval-LogsQueryOptions } public void singleQueryWithResponse() { @@ -106,10 +107,10 @@ public void singleQueryWithResponse() { .credential(new DefaultAzureCredentialBuilder().build()) .buildClient(); - // BEGIN: com.azure.monitor.query.LogsQueryClient.queryWithResponse#String-String-TimeInterval-LogsQueryOptions-Context + // BEGIN: com.azure.monitor.query.LogsQueryClient.queryWithResponse#String-String-QueryTimeInterval-LogsQueryOptions-Context Response queryResult = logsQueryClient.queryWithResponse("{workspace-id}", "{kusto-query}", - TimeInterval.LAST_7_DAYS, + QueryTimeInterval.LAST_7_DAYS, new LogsQueryOptions().setServerTimeout(Duration.ofMinutes(2)), Context.NONE); @@ -119,7 +120,7 @@ public void singleQueryWithResponse() { .map(LogsTableCell::getValueAsString) .collect(Collectors.joining(","))); } - // END: com.azure.monitor.query.LogsQueryClient.queryWithResponse#String-String-TimeInterval-LogsQueryOptions-Context + // END: com.azure.monitor.query.LogsQueryClient.queryWithResponse#String-String-QueryTimeInterval-LogsQueryOptions-Context } public void batchQueryAsync() { @@ -129,9 +130,9 @@ public void batchQueryAsync() { // BEGIN: com.azure.monitor.query.LogsQueryAsyncClient.queryBatch#LogsBatchQuery LogsBatchQuery batchQuery = new LogsBatchQuery(); - String queryId1 = batchQuery.addQuery("{workspace-id-1}", "{kusto-query-1}", TimeInterval.LAST_DAY); - String queryId2 = batchQuery.addQuery("{workspace-id-2}", "{kusto-query-2}", TimeInterval.LAST_7_DAYS, - new LogsQueryOptions().setServerTimeout(Duration.ofMinutes(2))); + String queryId1 = batchQuery.addQuery("{workspace-id-1}", "{kusto-query-1}", QueryTimeInterval.LAST_DAY); + String queryId2 = batchQuery.addQuery("{workspace-id-2}", "{kusto-query-2}", + QueryTimeInterval.LAST_7_DAYS, new LogsQueryOptions().setServerTimeout(Duration.ofMinutes(2))); Mono batchQueryResponse = logsQueryAsyncClient.queryBatch(batchQuery); @@ -156,9 +157,9 @@ public void batchQuery() { // BEGIN: com.azure.monitor.query.LogsQueryClient.queryBatch#LogsBatchQuery LogsBatchQuery batchQuery = new LogsBatchQuery(); - String queryId1 = batchQuery.addQuery("{workspace-id-1}", "{kusto-query-1}", TimeInterval.LAST_DAY); - String queryId2 = batchQuery.addQuery("{workspace-id-2}", "{kusto-query-2}", TimeInterval.LAST_7_DAYS, - new LogsQueryOptions().setServerTimeout(Duration.ofMinutes(2))); + String queryId1 = batchQuery.addQuery("{workspace-id-1}", "{kusto-query-1}", QueryTimeInterval.LAST_DAY); + String queryId2 = batchQuery.addQuery("{workspace-id-2}", "{kusto-query-2}", + QueryTimeInterval.LAST_7_DAYS, new LogsQueryOptions().setServerTimeout(Duration.ofMinutes(2))); LogsBatchQueryResultCollection batchQueryResponse = logsQueryClient.queryBatch(batchQuery); diff --git a/sdk/monitor/azure-monitor-query/src/test/java/com/azure/monitor/query/LogsQueryClientTest.java b/sdk/monitor/azure-monitor-query/src/test/java/com/azure/monitor/query/LogsQueryClientTest.java index c21a3ce60a189..b5d652b736746 100644 --- a/sdk/monitor/azure-monitor-query/src/test/java/com/azure/monitor/query/LogsQueryClientTest.java +++ b/sdk/monitor/azure-monitor-query/src/test/java/com/azure/monitor/query/LogsQueryClientTest.java @@ -6,7 +6,6 @@ import com.azure.core.credential.AccessToken; import com.azure.core.credential.TokenCredential; import com.azure.core.exception.HttpResponseException; -import com.azure.core.experimental.models.TimeInterval; import com.azure.core.http.policy.HttpLogDetailLevel; import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.policy.RetryPolicy; @@ -21,6 +20,8 @@ import com.azure.monitor.query.models.LogsBatchQueryResultCollection; import com.azure.monitor.query.models.LogsQueryOptions; import com.azure.monitor.query.models.LogsQueryResult; +import com.azure.monitor.query.models.LogsQueryResultStatus; +import com.azure.monitor.query.models.QueryTimeInterval; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; @@ -87,7 +88,7 @@ private TokenCredential getCredential() { @Test public void testLogsQuery() { LogsQueryResult queryResults = client.query(WORKSPACE_ID, "AppRequests", - new TimeInterval(OffsetDateTime.of(LocalDateTime.of(2021, 01, 01, 0, 0), ZoneOffset.UTC), + new QueryTimeInterval(OffsetDateTime.of(LocalDateTime.of(2021, 01, 01, 0, 0), ZoneOffset.UTC), OffsetDateTime.of(LocalDateTime.of(2021, 06, 10, 0, 0), ZoneOffset.UTC))); assertEquals(1, queryResults.getAllTables().size()); assertEquals(902, queryResults.getAllTables().get(0).getAllTableCells().size()); @@ -149,9 +150,9 @@ public void testBatchQueryPartialSuccess() { List responses = batchResultCollection.getBatchResults(); assertEquals(2, responses.size()); - assertEquals(200, responses.get(0).getStatus()); + assertEquals(LogsQueryResultStatus.SUCCESS, responses.get(0).getQueryResultStatus()); assertNull(responses.get(0).getError()); - assertEquals(400, responses.get(1).getStatus()); + assertEquals(LogsQueryResultStatus.FAILURE, responses.get(1).getQueryResultStatus()); assertNotNull(responses.get(1).getError()); assertEquals("BadArgumentError", responses.get(1).getError().getCode()); } @@ -178,10 +179,10 @@ public void testBatchStatistics() { List responses = batchResultCollection.getBatchResults(); assertEquals(2, responses.size()); - assertEquals(200, responses.get(0).getStatus()); + assertEquals(LogsQueryResultStatus.SUCCESS, responses.get(0).getQueryResultStatus()); assertNull(responses.get(0).getError()); assertNull(responses.get(0).getStatistics()); - assertEquals(200, responses.get(1).getStatus()); + assertEquals(LogsQueryResultStatus.SUCCESS, responses.get(1).getQueryResultStatus()); assertNull(responses.get(1).getError()); assertNotNull(responses.get(1).getStatistics()); } diff --git a/sdk/monitor/azure-monitor-query/src/test/java/com/azure/monitor/query/MetricsQueryClientTest.java b/sdk/monitor/azure-monitor-query/src/test/java/com/azure/monitor/query/MetricsQueryClientTest.java index 67ff4588e969c..8d5bc564615a5 100644 --- a/sdk/monitor/azure-monitor-query/src/test/java/com/azure/monitor/query/MetricsQueryClientTest.java +++ b/sdk/monitor/azure-monitor-query/src/test/java/com/azure/monitor/query/MetricsQueryClientTest.java @@ -5,7 +5,6 @@ import com.azure.core.credential.AccessToken; import com.azure.core.credential.TokenCredential; -import com.azure.core.experimental.models.TimeInterval; import com.azure.core.http.policy.HttpLogDetailLevel; import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.rest.PagedIterable; @@ -22,6 +21,7 @@ import com.azure.monitor.query.models.MetricDefinition; import com.azure.monitor.query.models.MetricsQueryOptions; import com.azure.monitor.query.models.MetricsQueryResult; +import com.azure.monitor.query.models.QueryTimeInterval; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -78,7 +78,7 @@ public void testMetricsQuery() { .queryWithResponse(RESOURCE_URI, Arrays.asList("SuccessfulCalls"), new MetricsQueryOptions() .setMetricNamespace("Microsoft.CognitiveServices/accounts") - .setTimeInterval(new TimeInterval(Duration.ofDays(10))) + .setTimeInterval(new QueryTimeInterval(Duration.ofDays(10))) .setGranularity(Duration.ofHours(1)) .setTop(100) .setAggregations(Arrays.asList(AggregationType.COUNT, AggregationType.TOTAL, diff --git a/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testBatchQueryPartialSuccess.json b/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testBatchQueryPartialSuccess.json index bcdb6350a13be..5fd2563052349 100644 --- a/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testBatchQueryPartialSuccess.json +++ b/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testBatchQueryPartialSuccess.json @@ -1,7 +1,7 @@ { "networkCallRecords" : [ { "Method" : "POST", - "Uri" : "https://REDACTED.loganalytics.io/v1/$batch", + "Uri" : "https://REDACTED.monitor.azure.com/v1/$batch", "Headers" : { "User-Agent" : "azsdk-java-UnknownName/UnknownVersion (11.0.8; Windows 10; 10.0)", "Content-Type" : "application/json" @@ -24,4 +24,4 @@ "Exception" : null } ], "variables" : [ ] -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testBatchStatistics.json b/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testBatchStatistics.json index c5e9e2e12b506..a597687a36165 100644 --- a/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testBatchStatistics.json +++ b/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testBatchStatistics.json @@ -1,7 +1,7 @@ { "networkCallRecords" : [ { "Method" : "POST", - "Uri" : "https://REDACTED.loganalytics.io/v1/$batch", + "Uri" : "https://REDACTED.monitor.azure.com/v1/$batch", "Headers" : { "User-Agent" : "azsdk-java-UnknownName/UnknownVersion (11.0.8; Windows 10; 10.0)", "Content-Type" : "application/json" @@ -24,4 +24,4 @@ "Exception" : null } ], "variables" : [ ] -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testLogsQuery.json b/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testLogsQuery.json index 1891722b1f14f..41251da934171 100644 --- a/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testLogsQuery.json +++ b/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testLogsQuery.json @@ -1,7 +1,7 @@ { "networkCallRecords" : [ { "Method" : "POST", - "Uri" : "https://REDACTED.loganalytics.io/v1/workspaces/d2d0e126-fa1e-4b0a-b647-250cdd471e68/query", + "Uri" : "https://REDACTED.monitor.azure.com/v1/workspaces/d2d0e126-fa1e-4b0a-b647-250cdd471e68/query", "Headers" : { "User-Agent" : "azsdk-java-UnknownName/UnknownVersion (11.0.8; Windows 10; 10.0)", "Content-Type" : "application/json" @@ -25,4 +25,4 @@ "Exception" : null } ], "variables" : [ ] -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testLogsQueryBatch.json b/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testLogsQueryBatch.json index 7025a531aeda5..df2aa75d5aaf6 100644 --- a/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testLogsQueryBatch.json +++ b/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testLogsQueryBatch.json @@ -1,7 +1,7 @@ { "networkCallRecords" : [ { "Method" : "POST", - "Uri" : "https://REDACTED.loganalytics.io/v1/$batch", + "Uri" : "https://REDACTED.monitor.azure.com/v1/$batch", "Headers" : { "User-Agent" : "azsdk-java-UnknownName/UnknownVersion (11.0.8; Windows 10; 10.0)", "Content-Type" : "application/json" @@ -24,4 +24,4 @@ "Exception" : null } ], "variables" : [ ] -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testMultipleWorkspaces.json b/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testMultipleWorkspaces.json index f22507c94f2df..d14d8905bcbd3 100644 --- a/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testMultipleWorkspaces.json +++ b/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testMultipleWorkspaces.json @@ -1,7 +1,7 @@ { "networkCallRecords" : [ { "Method" : "POST", - "Uri" : "https://REDACTED.loganalytics.io/v1/workspaces/d2d0e126-fa1e-4b0a-b647-250cdd471e68/query", + "Uri" : "https://REDACTED.monitor.azure.com/v1/workspaces/d2d0e126-fa1e-4b0a-b647-250cdd471e68/query", "Headers" : { "User-Agent" : "azsdk-java-UnknownName/UnknownVersion (11.0.8; Windows 10; 10.0)", "Content-Type" : "application/json" @@ -25,4 +25,4 @@ "Exception" : null } ], "variables" : [ ] -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testServerTimeout.json b/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testServerTimeout.json index 116fa6fa96e67..a93b8da76c566 100644 --- a/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testServerTimeout.json +++ b/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testServerTimeout.json @@ -1,7 +1,7 @@ { "networkCallRecords" : [ { "Method" : "POST", - "Uri" : "https://REDACTED.loganalytics.io/v1/workspaces/d2d0e126-fa1e-4b0a-b647-250cdd471e68/query", + "Uri" : "https://REDACTED.monitor.azure.com/v1/workspaces/d2d0e126-fa1e-4b0a-b647-250cdd471e68/query", "Headers" : { "User-Agent" : "azsdk-java-azure-monitor-query/1.0.0-beta.2 (11.0.11; Windows 10; 10.0)", "Content-Type" : "application/json" @@ -13,7 +13,7 @@ } }, { "Method" : "POST", - "Uri" : "https://REDACTED.loganalytics.io/v1/workspaces/d2d0e126-fa1e-4b0a-b647-250cdd471e68/query", + "Uri" : "https://REDACTED.monitor.azure.com/v1/workspaces/d2d0e126-fa1e-4b0a-b647-250cdd471e68/query", "Headers" : { "User-Agent" : "azsdk-java-azure-monitor-query/1.0.0-beta.2 (11.0.11; Windows 10; 10.0)", "Content-Type" : "application/json" @@ -25,7 +25,7 @@ } }, { "Method" : "POST", - "Uri" : "https://REDACTED.loganalytics.io/v1/workspaces/d2d0e126-fa1e-4b0a-b647-250cdd471e68/query", + "Uri" : "https://REDACTED.monitor.azure.com/v1/workspaces/d2d0e126-fa1e-4b0a-b647-250cdd471e68/query", "Headers" : { "User-Agent" : "azsdk-java-azure-monitor-query/1.0.0-beta.2 (11.0.11; Windows 10; 10.0)", "Content-Type" : "application/json" @@ -49,4 +49,4 @@ "Exception" : null } ], "variables" : [ ] -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testStatistics.json b/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testStatistics.json index 31c7d53f6a7d4..ee7d6f7f0fd66 100644 --- a/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testStatistics.json +++ b/sdk/monitor/azure-monitor-query/src/test/resources/session-records/LogsQueryClientTest.testStatistics.json @@ -1,7 +1,7 @@ { "networkCallRecords" : [ { "Method" : "POST", - "Uri" : "https://REDACTED.loganalytics.io/v1/workspaces/d2d0e126-fa1e-4b0a-b647-250cdd471e68/query", + "Uri" : "https://REDACTED.monitor.azure.com/v1/workspaces/d2d0e126-fa1e-4b0a-b647-250cdd471e68/query", "Headers" : { "User-Agent" : "azsdk-java-UnknownName/UnknownVersion (11.0.8; Windows 10; 10.0)", "Content-Type" : "application/json" @@ -25,4 +25,4 @@ "Exception" : null } ], "variables" : [ ] -} \ No newline at end of file +}