Share via


LogsBatchQuery Class

Definition

Represents a batch that consists of multiple log queries.

public class LogsBatchQuery
type LogsBatchQuery = class
Public Class LogsBatchQuery
Inheritance
LogsBatchQuery

Constructors

LogsBatchQuery()

Initializes a new instance of LogsBatchQuery.

Methods

AddWorkspaceQuery(String, String, QueryTimeRange, LogsQueryOptions)

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.AddWorkspaceQuery(
    workspaceId,
    "AzureActivity | count",
    new QueryTimeRange(TimeSpan.FromDays(1)));
string topQueryId = batch.AddWorkspaceQuery(
    workspaceId,
    "AzureActivity | summarize Count = count() by ResourceGroup | top 10 by Count",
    new QueryTimeRange(TimeSpan.FromDays(1)));

Response<LogsBatchQueryResultCollection> response = await client.QueryBatchAsync(batch);

var count = response.Value.GetResult<int>(countQueryId).Single();
var topEntries = response.Value.GetResult<MyLogEntryModel>(topQueryId);

Applies to