应用洞察,将时差转换为毫秒

时间:2017-06-07 20:12:23

标签: azure-application-insights ms-app-analytics

如何在Azure Application Insights中将时差转换为毫秒

let startTime = todatetime('2017-05-15T17:02:23.7148691Z');
let endTime = todatetime('2017-05-15T17:02:25.5430172Z');
let timeDifference = endTime-startTime;
requests
| project timeDifference
| limit 1

以上查询输出

00:00:01.8281481

我想以毫秒显示它

例如:1828

2 个答案:

答案 0 :(得分:2)

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

let startTime = todatetime('2017-05-15T17:02:23.7148691Z');
let endTime = todatetime('2017-05-15T17:02:25.5430172Z');
let timeDifference = endTime-startTime;
// get total milliseconds 
requests
| extend timeDifferenceMilliseconds = timeDifference / time(1ms)
| project timeDifferenceMilliseconds
| limit 1

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

答案 1 :(得分:1)

另一种解决方案是使用内置的 datetime_diff 函数并指定毫秒:

let startTime = todatetime('2017-05-15T17:02:23.7148691Z');
let endTime = todatetime('2017-05-15T17:02:25.5430172Z');
let timeDifference = datetime_diff("Millisecond", endTime, startTime);
requests
| project timeDifference
| limit 1

文档在这里:https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/datetime-difffunction