首页 > 解决方案 > Metric.TryGetDataSeries returning false, despite dimensions cap being respected

问题描述

I am trying to use the Metric.TryGetDataSeries Method (documented here: https://docs.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___) to obtain a MetricSeries which can then be used to send metrics as follows:

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)}");
}

However, our logging shows we are seeing exceptions consistently. Example log: Failed to create metric DownloadReadDurationInMs with dimensions: Filename,StreamSzInKB,DataSourceId. Screenshot of log below for good measure:

Failed to create metric DownloadReadDurationInMs with dimensions: Filename,StreamSzInKB,DataSourceId.

In other words, we are seeing TryGetDataSeries return false in some cases. Per the docs, the function returns as follows:

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.

Clearly createIfNotExists == true, so it must be that "a dimension cap or a metric series cap was reached". But if we look at our logs, there are 3 dimensions, so I don't think any cap is being exceeded either (though I don't know where to look to verify this - same thing with the "series cap" too).

So, questions:

  1. What are the exact values of these dimensions/series caps?
  2. Assuming I am not exceeding those caps (based on the logs, it seems likely that I am within the cap), is there something else that could be going wrong here?

标签: azureazure-application-insightsmetrics

解决方案


我被指出了这个文档(仅在 3 周前添加!)https://docs.microsoft.com/en-us/azure/azure-monitor/app/get-metric#dimension-and-time-series-capping其中有关尺寸和系列上限的详细信息。

根据文档:

默认限制是每个指标不超过 1000 个总数据系列,每个维度不超过 100 个不同的值。

我对“独特价值”上限感到惊讶,因此我似乎实际上超过了这个上限。这一起回答了我的第一个和第二个问题。


推荐阅读