Compartilhar via


LogsBatchQuery.AddWorkspaceQuery Método

Definição

Adiciona a consulta especificada ao lote. Os resultados podem ser recuperados depois que a consulta é enviada por meio da QueryBatchAsync(LogsBatchQuery, CancellationToken) chamada.

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);
public virtual string AddWorkspaceQuery (string workspaceId, string query, Azure.Monitor.Query.QueryTimeRange timeRange, Azure.Monitor.Query.LogsQueryOptions options = default);
abstract member AddWorkspaceQuery : string * string * Azure.Monitor.Query.QueryTimeRange * Azure.Monitor.Query.LogsQueryOptions -> string
override this.AddWorkspaceQuery : string * string * Azure.Monitor.Query.QueryTimeRange * Azure.Monitor.Query.LogsQueryOptions -> string
Public Overridable Function AddWorkspaceQuery (workspaceId As String, query As String, timeRange As QueryTimeRange, Optional options As LogsQueryOptions = Nothing) As String

Parâmetros

workspaceId
String

O workspace a ser incluído na consulta.

query
String

O texto da consulta a ser executado.

timeRange
QueryTimeRange

O intervalo de tempo sobre o qual consultar dados.

options
LogsQueryOptions

O LogsQueryOptions para configurar a consulta.

Retornos

O identificador de consulta que deve ser passado GetResult(String) para obter o resultado.

Aplica-se a