LogsQueryClient.QueryBatch(LogsBatchQuery, CancellationToken) Method
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.
Submits the batch query. Use the LogsBatchQuery to compose a batch query.
string workspaceId = "<workspace_id>";
var client = new LogsQueryClient(new DefaultAzureCredential());
// Query TOP 10 resource groups by event count
// And total event count
var batch = new LogsBatchQuery();
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);
Console.WriteLine($"AzureActivity has total {count} events");
foreach (var logEntryModel in topEntries)
{
Console.WriteLine($"{logEntryModel.ResourceGroup} had {logEntryModel.Count} events");
}
public virtual Azure.Response<Azure.Monitor.Query.Models.LogsBatchQueryResultCollection> QueryBatch (Azure.Monitor.Query.LogsBatchQuery batch, System.Threading.CancellationToken cancellationToken = default);
abstract member QueryBatch : Azure.Monitor.Query.LogsBatchQuery * System.Threading.CancellationToken -> Azure.Response<Azure.Monitor.Query.Models.LogsBatchQueryResultCollection>
override this.QueryBatch : Azure.Monitor.Query.LogsBatchQuery * System.Threading.CancellationToken -> Azure.Response<Azure.Monitor.Query.Models.LogsBatchQueryResultCollection>
Public Overridable Function QueryBatch (batch As LogsBatchQuery, Optional cancellationToken As CancellationToken = Nothing) As Response(Of LogsBatchQueryResultCollection)
- batch
- LogsBatchQuery
The batch of queries to send.
- cancellationToken
- CancellationToken
The CancellationToken to use.
The LogsBatchQueryResultCollection containing the query identifier that has to be passed into GetResult(String) to get the result.
Product | Versions |
---|---|
Azure SDK for .NET | Latest, Preview |
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Azure SDK for .NET feedback
Azure SDK for .NET is an open source project. Select a link to provide feedback: