azure - 使用 Azure 时序见解资源管理器中的时序表达式语法获取两个日期之间的差异(以秒为单位)

标签 azure azure-eventhub azure-timeseries-insights

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

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

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

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

enter image description here

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

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

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

enter image description here

有没有办法使用时间序列见解和 TSX(时间序列表达式)来实现这一目标?

谢谢!

最佳答案

enter image description here

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

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

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

语法:

datetime_diff(周期,datetime_1,datetime_2)

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

关于azure - 使用 Azure 时序见解资源管理器中的时序表达式语法获取两个日期之间的差异(以秒为单位),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71774069/

相关文章:

azure - 如何向 Azure 时间序列见解查询 API 进行身份验证?

azure - Azure 中是否有像 AWS 中那样可用的实例配置文件

azure - 通过 Azure Functions 处理 Azure 事件中心事件与使用 Azure.Messaging.EventHub SDK 的 .NET 控制台应用程序处理 Azure 事件中心事件,有任何实际差异吗?

azure - 如何在不注册任何应用程序的情况下通过API访问Azure时间序列见解?

c# - Azure 事件中心 - 如何在 .Net Core WebAPI 中实现使用者?

ruby - 为 azure 服务总线/eventhubs 生成有效的授权 header

azure - 如何按设备 ID 筛选从 IoT 中心消耗的 Azure Timeseries Insights 事件

azure - 如何获取Azure数据工厂管道的静态IP?

c# - 给定 PartitionKey、RowKey、属性名称和值,如何更新该实体的属性值?

sql-server - 错误 SQL71624 : The permission 'CONNECT' is not valid for the target object 'guest' in Microsoft Azure SQL Database v12