3

如何在 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

4

2 回答 2

3

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

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

于 2017-06-07T22:47:40.880 回答
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

于 2021-01-05T01:23:00.160 回答