简体   繁体   English

KQL 连接两个具有不同时间戳的表

[英]KQL join two tables with different TimeStamp

I´m working with KQL and trying to join two tables on a timestamp field.我正在使用 KQL 并尝试在时间戳字段上连接两个表。 The problem is that they have different values when it comes to seconds.问题是它们在秒方面有不同的值。

The table "TableToJoin" will ingest record every minute (so seconds are 00) and the MeasureTime column I made will have different seconds depending on when I hit the run button (knowing it will starting counting 36h from now)表“TableToJoin”将每分钟摄取一次记录(所以秒为 00),我制作的 MeasureTime 列将根据我点击运行按钮的时间有不同的秒数(知道它将从现在开始计数 36 小时)

Do you know a method I could use to fix this?你知道我可以用来解决这个问题的方法吗?

I paste my code below:我在下面粘贴我的代码:

range MeasureTime from ago(36h) to now() step(10m) 
| join kind=rightouter 
(TableToJoin| where TagName == 'TagName') on $left.MeasureTime == $right.Timestamp | take 10

TableToJoin TimeStamp: TableToJoin 时间戳:

2021-11-01T14:09:00Z
2021-11-01T14:08:00Z
2021-11-01T14:06:00Z
2021-11-01T14:05:00Z
2021-11-01T14:04:00Z
2021-11-01T14:03:00Z
2021-11-01T14:02:00Z
2021-11-01T14:01:00Z
2021-11-01T14:00:00Z

MeasureTime TimeStamp: MeasureTime 时间戳:

2021-11-01T13:59:20.5230363Z
2021-11-01T14:00:20.5230363Z
2021-11-01T14:01:20.5230363Z
2021-11-01T14:02:20.5230363Z
2021-11-01T14:03:20.5230363Z
2021-11-01T14:04:20.5230363Z
2021-11-01T14:05:20.5230363Z
2021-11-01T14:06:20.5230363Z

Thanks in advance提前致谢

You can use the bin() function to "round" the timestamp.您可以使用 bin() 函数来“舍入”时间戳。 For example:例如:

range MeasureTime from ago(36h) to now() step(10m) 
| extend MeasureTime = bin(MeasureTime, 10s)
| join kind=rightouter (
    TableToJoin| where TagName == 'TagName'
) on $left.MeasureTime == $right.Timestamp | take 10

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM