使用 Azure 时序见解资源管理器中的时序表达式语法获取两个日期之间的秒数差异

Get difference between two dates in seconds using Time Series Expression Syntax in Azure Time Series Insights Explorer

我有一个事件中心将数据发送到时间序列见解,消息格式如下:

{
  "deviceId" : "Device1",
  "time" : "2022-03-30T21:27:29Z"
}

我想计算事件中心 EnqueuedTimeUtc 属性 和 time 属性 之间的秒数差异.

我创建了带有事件源的时间序列见解,但未指定 时间戳 属性 名称,在时间序列见解中,我们的时间戳 ($ts) 属性 将是事件的 EnqueuedTimeUtc 属性。

现在有了这两个属性,使用 TSX(时间序列表达式语言),我想做这样的事情:

$event.$ts - $event.time.DateTime

我面临的问题是该操作的结果 returns 日期时间,但在时间序列表达式中没有将日期时间转换为秒或 Unix 时间戳的函数。 Time Series Expresion Doc

有没有办法使用 Time Series Insights 和 TSX(Time Series Expression)来实现这一点?

谢谢!

TSI 是 Azure 中的一项折旧服务,其中没有太多可用于探索数据的功能(内置功能)。因此,我建议你使用 Azure 数据资源管理器来处理事件中心数据。

Azure 数据资源管理器提供内置 datetime_diff 函数,允许使用简单的 Kusto 查询语言根据您的要求计算多种支持格式的周期。

datetime_diff(): 计算两个日期时间值之间的日历差异。

语法:

datetime_diff(period,datetime_1,datetime_2)

示例: second = datetime_diff('second',datetime(2017-10-30 23:00:10.100),datetime(2017-10-30 23:00:00.900))