我正在尝试使用 Metric.TryGetDataSeries 方法(此处记录:https://learn.microsoft.com/en-us/dotnet/api/microsoft.applicationinsights.metric.trygetdataseries?view=azure-dotnet#Microsoft_ApplicationInsights_Metric_TryGetDataSeries_Microsoft_ApplicationInsights_Metrics_MetricSeries__System_Boolean_System_String___)来获取 MetricSeries,然后可以使用该方法发送指标,如下所示:
MetricSeries series;
bool canTrack = metric.TryGetDataSeries(out series, true, dimensionValuesWithCanvasId.ToArray());
if (canTrack)
{
series.TrackValue(value);
}
else
{
throw new Exception($"Failed to track value for metric with dimensions: {string.Join(",", this.dimensionNames)}");
}
但是,我们的日志记录显示我们始终看到异常情况。日志示例:无法创建维度为 DownloadReadDurationInMs 的指标:Filename、StreamSzInKB、DataSourceId。下面的日志屏幕截图是很好的衡量标准:
换句话说,我们看到 TryGetDataSeries 在某些情况下返回 false。根据文档,该函数返回如下:
True if the MetricSeries indicated by the specified dimension names could be retrieved or created; False if the indicated series could not be retrieved or created because createIfNotExists is false or because a dimension cap or a metric series cap was reached.
显然createIfNotExists == true,所以一定是“达到了维度上限或公制系列上限”。但如果我们查看日志,就会发现有 3 个维度,所以我认为也没有超出任何上限(尽管我不知道在哪里可以验证这一点 - 与“系列上限”也是如此)。
那么,问题:
- 这些尺寸/系列上限的确切值是多少?
- 假设我没有超过这些上限(根据日志,我似乎在上限之内),这里是否还有其他可能出错的地方?
最佳答案
有人向我指出了此文档(仅在 3 周前添加!)https://learn.microsoft.com/en-us/azure/azure-monitor/app/get-metric#dimension-and-time-series-capping其中详细介绍了尺寸和系列上限的信息。
根据文档:
The default limits are no more than 1000 total data series per metric, and no more than 100 different values per dimension.
我对“独特值(value)”上限感到惊讶,因此看来我实际上超出了此上限。这共同回答了我的第一个问题和第二个问题。
关于azure - 尽管遵守维度上限,Metric.TryGetDataSeries 返回 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61879852/