如何使用 api 获取 Azure apim 的指标

How to get metrics of Azure apim using an api

我必须在 C# 上制作一个程序来获取有关 Azure APIM 的几个 api 的信息,我可以通过 api 实现吗?

您可以尝试的解决方法之一是从存储 API 管理

指标的 Azure Monitor 获取查看的诊断数据

用于列出资源的指标

IEnumerable<Metric> metrics = await readOnlyClient.Metrics.ListAsync(resourceUri: resourceUri, cancellationToken: CancellationToken.None);

或使用过滤器

// The comma-separated list of metric names must be present if a filter is used
var metricNames = "name.value eq 'CpuPercentage'"; // could be concatenated with " or name.value eq '<another name>'" ...

// Time grain is optional when metricNames is present
string timeGrain = " and timeGrain eq duration'PT5M'";

// Defaulting to 3 hours before the time of execution for these datetimes
string startDate = string.Format(" and startTime eq {0}", DateTime.Now.AddHours(-3).ToString("o"));
string endDate = string.Format(" and endTime eq {0}", DateTime.Now.ToString("o"));

var odataFilterMetrics = new ODataQuery<Metric>(
    string.Format(
        "{0}{1}{2}{3}",
        metricNames,
        timeGrain,
        startDate,
        endDate));

Write("Call with filter parameter (i.e. $filter = {0})", odataFilterMetrics);
metrics = await readOnlyClient.Metrics.ListAsync(resourceUr

参考文献: