azure - 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:
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:
- What are the exact values of these dimensions/series caps?
- 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?
解决方案
我被指出了这个文档(仅在 3 周前添加!)https://docs.microsoft.com/en-us/azure/azure-monitor/app/get-metric#dimension-and-time-series-capping其中有关尺寸和系列上限的详细信息。
根据文档:
默认限制是每个指标不超过 1000 个总数据系列,每个维度不超过 100 个不同的值。
我对“独特价值”上限感到惊讶,因此我似乎实际上超过了这个上限。这一起回答了我的第一个和第二个问题。
推荐阅读
- python - ValueError:Series 的真值不明确。使用 a.empty、a.bool()、a.item()、a.any() 或 a.all() 不知道
- python - 即使安装了python模块也找不到
- javascript - 为什么我可以将 Vue 模板导入 EJS 文件?
- python - 骰子总和游戏
- singularity-container - 无法构建可写奇点容器
- mysql - 我已经编写了查询以在给数据库中以 S 和 V 开头的名称排序,出现的错误如下
- python - 我正确使用 os.system 吗?我的应用程序将不再打开
- javascript - 回调函数中 this 的上下文
- sql - SQL 函数调用
- typescript - Typescript 类方法,它采用调用者的实例类型