MetricsQueryClient.QueryResource Método
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Consulta as métricas de um recurso.
string resourceId =
"/subscriptions/<subscription_id>/resourceGroups/<resource_group_name>/providers/<resource_provider>/<resource>";
var client = new MetricsQueryClient(new DefaultAzureCredential());
Response<MetricsQueryResult> results = await client.QueryResourceAsync(
resourceId,
new[] { "Average_% Free Space", "Average_% Used Space" }
);
foreach (MetricResult metric in results.Value.Metrics)
{
Console.WriteLine(metric.Name);
foreach (MetricTimeSeriesElement element in metric.TimeSeries)
{
Console.WriteLine("Dimensions: " + string.Join(",", element.Metadata));
foreach (MetricValue value in element.Values)
{
Console.WriteLine(value);
}
}
}
public virtual Azure.Response<Azure.Monitor.Query.Models.MetricsQueryResult> QueryResource (string resourceId, System.Collections.Generic.IEnumerable<string> metrics, Azure.Monitor.Query.MetricsQueryOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member QueryResource : string * seq<string> * Azure.Monitor.Query.MetricsQueryOptions * System.Threading.CancellationToken -> Azure.Response<Azure.Monitor.Query.Models.MetricsQueryResult>
override this.QueryResource : string * seq<string> * Azure.Monitor.Query.MetricsQueryOptions * System.Threading.CancellationToken -> Azure.Response<Azure.Monitor.Query.Models.MetricsQueryResult>
Public Overridable Function QueryResource (resourceId As String, metrics As IEnumerable(Of String), Optional options As MetricsQueryOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Response(Of MetricsQueryResult)
Parâmetros
- resourceId
- String
O nome do recurso.
Por exemplo: /subscriptions/<subscription_id>/resourceGroups/<resource_group_name>/providers/<resource_provider>/<resource>
,/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/resource-group/providers/Microsoft.Storage/storageAccounts/mystorage
,/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/resource-group/providers/Microsoft.Compute/virtualMachines/myvm
- metrics
- IEnumerable<String>
A lista de métricas a serem consultada.
- options
- MetricsQueryOptions
As opções de solicitação adicionais.
- cancellationToken
- CancellationToken
O CancellationToken a ser usado.
Retornos
A MetricsQueryResult instância que contém os resultados da consulta.
Aplica-se a
Azure SDK for .NET