在Analytics Query Language中获取总时间跨度的毫秒数

时间:2017-06-02 16:20:15

标签: azure-application-insights

我尝试在Application Insights Analytics中渲染两个日期之间的差异,但时间跨度不是时间图y轴的受支持类型。

示例查询:

customMetrics
| extend dateDiff = timestamp - (timestamp - 1m) 
// my second date comes from customDimensions
| summarize max(dateDiff) by bin(timestamp, 10m)
| order by timestamp desc
| render timechart

我想将dateDiff时间跨度转换为表示毫秒数的整数,但我无法在其文档中找到支持此内容的任何内容。我基本上想要C#&#39的TimeSpan.TotalMilliseconds()。

1 个答案:

答案 0 :(得分:6)

您可以将时间跨度除以另一个时间跨度。因此,要获得毫秒数,您可以执行以下操作:

customMetrics
| extend dateDiff = timestamp - (timestamp - 1m)
// get total milliseconds 
| extend dateDiffMilliseconds = dateDiff / time(1ms)
// my second date comes from customDimensions
| summarize max(dateDiff) by bin(timestamp, 10m)
| order by timestamp desc
| render timechart

有关日期和时间表达式的更多信息,请访问:https://docs.microsoft.com/en-us/azure/application-insights/app-insights-analytics-reference#date-and-time-expressions