如何对 Azure AppInsights 中的自定义指标进行百分位数计算?

How to do percentiles on custom metrics in Azure AppInsights?

我使用 Prometheus 存储 performance metrics and query the results as percentiles (ex. 95th percentile response timing). I used prometheus-net 来发射它们。

Azure AppInsights 中的等效项是什么?

我看到 AppInsights/Kusto 中有 percentile functions,但是当我使用 GetMetric("blah").TrackValue(42) 时,它会存储 Count、Min、Max、Sum 和 StdDev,这不是我在 Prometheus 中使用的直方图分桶方法。

for(int i=0; i < 500; i++) {
  //Write some metrics
  telemetryClient.GetMetric("blah").TrackValue(42); //real data isn't constant
}
customMetrics
| where name == "blah" 
//| summarize avg(value), percentiles(value, 50, 95)  by bin(timestamp, 2m)

这是我用随机值记录的一些数据。值列是总和,这是不正确的,所以我看不出如何正确地对该数据进行百分位数计算。

GetMetric().TrackValue() API与默认聚合一起使用时,不会存储每个单独的值,1分钟后会生成一个值,并使用sum/count/min/max/将该值发送给AI ... 分配。因此,以后无法在 Analytics 中绘制原始数据点的百分位数。

GetMetric().TrackValue() API 目前只有很少的聚合可用,直方图/tdigest 不是其中之一。您可以在 AI SDK GitHub repository.

上提交功能请求(或贡献)

目前的解决方法是使用较旧的 API,默认情况下提交时间点指标而不聚合:TrackMetric() 或 [=13= 中的一系列测量].这将增加发送的遥测项目的数量(每个指标将单独发送,而不对值进行 1 分钟聚合),但这将为您提供每个值以在必要时在 Analytics 中执行百分位数聚合。