gpt4 book ai didi

c# - 如何使用 REST API 筛选 AppInsights 自定义指标

转载 作者:行者123 更新时间:2023-12-03 00:48:15 24 4
gpt4 key购买 nike

我尝试使用 REST API 检索 AppInsights 自定义指标并在查询中使用过滤器。

创建指标的代码:

var telemetry = new MetricTelemetry();
telemetry.Context.InstrumentationKey = instrumentationKey;
telemetry.Name = FacebookFupMetricName;
telemetry.Value = amount;
telemetry.Timestamp = DateTime.Now;
telemetry.Properties["agencyCode"] = agencyCode;
telemetry.Properties["accountCode"] = accountCode;
telemetry.Properties["category"] = category;
telemetry.Properties["action"] = action;
var client = new TelemetryClient();
client.TrackMetric(telemetry);
client.Flush();

运行此代码时,该指标是在 Azure 中创建的。

现在我想使用 REST API 来检索指标并在查询中使用过滤器。当我使用过滤器时

category eq 'cat001'

查询以错误结束

The following dimensions are not valid in the filter clause for this metric: category

查询网址为:

https://dev.applicationinsights.io/apiexplorer/metrics?appId=<appId>&apiKey=<apiKey>&metricId=customMetrics%2FFacebookFupAction&timespan=P1D&aggregation=sum&filter=category%20eq%20%27cat001%27

问题是,是否可以使用维度过滤自定义指标?

最佳答案

在过滤器字段中,您应该使用customDimensions/category eq 'cat001'

生成的url格式如下:

`https://dev.applicationinsights.io/apiexplorer/metrics?appId=<appId>&apiKey=<apiKey>&metricId=customMetrics%2FFacebookFupMetricName&aggregation=sum&filter=customDimensions%2Fcategory%20eq%20'cat001'`

截图如下:

enter image description here

关于c# - 如何使用 REST API 筛选 AppInsights 自定义指标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58415335/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com