public final class LogsQueryClient extends Object
Instantiating a synchronous Logs query Client
LogsQueryClient logsQueryClient = new LogsQueryClientBuilder() .credential(tokenCredential) .buildClient();
Modifier and Type | Method and Description |
---|---|
LogsQueryResult |
query(String workspaceId,
String query,
com.azure.core.experimental.models.TimeInterval timeInterval)
Returns all the Azure Monitor logs matching the given query in the specified workspaceId.
|
<T> List<T> |
query(String workspaceId,
String query,
com.azure.core.experimental.models.TimeInterval timeInterval,
Class<T> type)
Returns all the Azure Monitor logs matching the given query in the specified workspaceId.
|
<T> List<T> |
query(String workspaceId,
String query,
com.azure.core.experimental.models.TimeInterval timeInterval,
Class<T> type,
LogsQueryOptions options)
Returns all the Azure Monitor logs matching the given query in the specified workspaceId.
|
LogsBatchQueryResultCollection |
queryBatch(LogsBatchQuery logsBatchQuery)
Returns all the Azure Monitor logs matching the given batch of queries.
|
com.azure.core.http.rest.Response<LogsBatchQueryResultCollection> |
queryBatchWithResponse(LogsBatchQuery logsBatchQuery,
com.azure.core.util.Context context)
Returns all the Azure Monitor logs matching the given batch of queries.
|
<T> com.azure.core.http.rest.Response<List<T>> |
queryWithResponse(String workspaceId,
String query,
com.azure.core.experimental.models.TimeInterval timeInterval,
Class<T> type,
LogsQueryOptions options,
com.azure.core.util.Context context)
Returns all the Azure Monitor logs matching the given query in the specified workspaceId.
|
com.azure.core.http.rest.Response<LogsQueryResult> |
queryWithResponse(String workspaceId,
String query,
com.azure.core.experimental.models.TimeInterval timeInterval,
LogsQueryOptions options,
com.azure.core.util.Context context)
Returns all the Azure Monitor logs matching the given query in the specified workspaceId.
|
public LogsQueryResult query(String workspaceId, String query, com.azure.core.experimental.models.TimeInterval timeInterval)
Query logs from the last 24 hours
LogsQueryResult queryResult = logsQueryClient.query("{workspace-id}", "{kusto-query}", TimeInterval.LAST_DAY); for (LogsTableRow row : queryResult.getTable().getRows()) { System.out.println(row.getRow() .stream() .map(LogsTableCell::getValueAsString) .collect(Collectors.joining(","))); }
workspaceId
- The workspaceId where the query should be executed.query
- The Kusto query to fetch the logs.timeInterval
- The time period for which the logs should be looked up.public <T> List<T> query(String workspaceId, String query, com.azure.core.experimental.models.TimeInterval timeInterval, Class<T> type)
T
- The type the result of this query should be mapped to.workspaceId
- The workspaceId where the query should be executed.query
- The Kusto query to fetch the logs.timeInterval
- The time period for which the logs should be looked up.type
- The type the result of this query should be mapped to.public <T> List<T> query(String workspaceId, String query, com.azure.core.experimental.models.TimeInterval timeInterval, Class<T> type, LogsQueryOptions options)
T
- The type the result of this query should be mapped to.workspaceId
- The workspaceId where the query should be executed.query
- The Kusto query to fetch the logs.timeInterval
- The time period for which the logs should be looked up.type
- The type the result of this query should be mapped to.options
- The log query options to configure server timeout, set additional workspaces or enable
statistics and rendering information in response.public com.azure.core.http.rest.Response<LogsQueryResult> queryWithResponse(String workspaceId, String query, com.azure.core.experimental.models.TimeInterval timeInterval, LogsQueryOptions options, com.azure.core.util.Context context)
Query logs from the last 7 days and set the service timeout to 2 minutes
Response<LogsQueryResult> queryResult = logsQueryClient.queryWithResponse("{workspace-id}", "{kusto-query}", TimeInterval.LAST_7_DAYS, new LogsQueryOptions().setServerTimeout(Duration.ofMinutes(2)), Context.NONE); for (LogsTableRow row : queryResult.getValue().getTable().getRows()) { System.out.println(row.getRow() .stream() .map(LogsTableCell::getValueAsString) .collect(Collectors.joining(","))); }
workspaceId
- The workspaceId where the query should be executed.query
- The Kusto query to fetch the logs.timeInterval
- The time period for which the logs should be looked up.options
- The log query options to configure server timeout, set additional workspaces or enable
statistics and rendering information in response.context
- Additional context that is passed through the Http pipeline during the service call. If no
additional context is required, pass Context.NONE
instead.public <T> com.azure.core.http.rest.Response<List<T>> queryWithResponse(String workspaceId, String query, com.azure.core.experimental.models.TimeInterval timeInterval, Class<T> type, LogsQueryOptions options, com.azure.core.util.Context context)
T
- The type the result of this query should be mapped to.workspaceId
- The workspaceId where the query should be executed.query
- The Kusto query to fetch the logs.timeInterval
- The time period for which the logs should be looked up.type
- The type the result of this query should be mapped to.options
- The log query options to configure server timeout, set additional workspaces or enable
statistics and rendering information in response.context
- Additional context that is passed through the Http pipeline during the service call. If no
additional context is required, pass Context.NONE
instead.public LogsBatchQueryResultCollection queryBatch(LogsBatchQuery logsBatchQuery)
Execute a batch of logs queries
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))); LogsBatchQueryResultCollection batchQueryResponse = logsQueryClient.queryBatch(batchQuery); for (LogsBatchQueryResult queryResult : batchQueryResponse.getBatchResults()) { System.out.println("Logs query result for query id " + queryResult.getId()); for (LogsTableRow row : queryResult.getTable().getRows()) { System.out.println(row.getRow() .stream() .map(LogsTableCell::getValueAsString) .collect(Collectors.joining(","))); } }
logsBatchQuery
- LogsBatchQuery
containing a batch of queries.public com.azure.core.http.rest.Response<LogsBatchQueryResultCollection> queryBatchWithResponse(LogsBatchQuery logsBatchQuery, com.azure.core.util.Context context)
logsBatchQuery
- LogsBatchQuery
containing a batch of queries.context
- Additional context that is passed through the Http pipeline during the service call. If no
additional context is required, pass Context.NONE
instead.Copyright © 2021 Microsoft Corporation. All rights reserved.