LogsBatchQuery.AddQuery(String, String, DateTimeRange, LogsQueryOptions) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds the specified query to the batch. Results can be retrieved after the query is submitted via the QueryBatchAsync(LogsBatchQuery, CancellationToken) call.
string countQueryId = batch.AddQuery(
workspaceId,
"AzureActivity | count",
new DateTimeRange(TimeSpan.FromDays(1)));
string topQueryId = batch.AddQuery(
workspaceId,
"AzureActivity | summarize Count = count() by ResourceGroup | top 10 by Count",
new DateTimeRange(TimeSpan.FromDays(1)));
Response<LogsBatchQueryResults> response = await client.QueryBatchAsync(batch);
var count = response.Value.GetResult<int>(countQueryId).Single();
var topEntries = response.Value.GetResult<MyLogEntryModel>(topQueryId);
public virtual string AddQuery (string workspace, string query, Azure.Core.DateTimeRange timeRange, Azure.Monitor.Query.LogsQueryOptions options = default);
abstract member AddQuery : string * string * Azure.Core.DateTimeRange * Azure.Monitor.Query.LogsQueryOptions -> string
override this.AddQuery : string * string * Azure.Core.DateTimeRange * Azure.Monitor.Query.LogsQueryOptions -> string
Public Overridable Function AddQuery (workspace As String, query As String, timeRange As DateTimeRange, Optional options As LogsQueryOptions = Nothing) As String
Parameters
- workspace
- System.String
The workspace to include in the query.
- query
- System.String
The query text to execute.
- timeRange
- DateTimeRange
The timespan over which to query data.
- options
- LogsQueryOptions
The LogsQueryOptions to configure the query.
Returns
- System.String
The query identifier that has to be passed into GetResult(String) to get the result.