我有两个Rawdata事件,其中一个是带有一个时间戳的请求,另一个是具有不同时间跨度的响应,是否有一个kusto函数可以从rawdata中提取这两个日期并在两者之间进行时差< / p>
答案 0 :(得分:0)
是的,有。
在没有看到输入数据样本的情况下为您提供最佳选择有些挑战,但是您可能需要查看parse
运算符:https://docs.microsoft.com/en-us/azure/kusto/query/parseoperator或extract()
函数:{{3 }}
或者,在您的问题中包含示例输入,例如以下内容:
print request = "this<>is!!!my-request from 2019-08-14 17:54:36.8892211, the end",
response = "this is the matching 2019-08-14 17:55:36.0000033 response"
| parse request with * "from " request_datetime:datetime "," *
| parse response with * "matching " response_datetime:datetime " response"
| project diff = response_datetime - request_datetime
// this returns a single table with a single column named 'diff', whose value is '00:00:59.1107822'
或
datatable(event_text:string, correlation_id:long) [
"this<>is!!!my-request from 2019-08-14 17:54:36.8892211, the end", 1,
"this is the matching 2019-08-14 17:55:36.0000033 response", 1,
]
| extend dt = extract(@"(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{7})", 1, event_text, typeof(datetime))
| summarize diff = max(dt) - min(dt) by correlation_id
// this returns a single table with 2 columns named 'correlation_id' and 'diff', whose values are are '1' and '00:00:59.1107822'
答案 1 :(得分:0)
Yoni 的回答向您展示了如何提取时间戳。拥有它们后,您可以使用 datetime_diff
函数。假设您想知道 2 个时间戳之间相差多少秒:
| extend TimeDiff = datetime_diff('second', SigninTime, EventTime)
您可以使用此信息进行过滤。假设您只想保留这些时间戳彼此在 20 秒内的行:
| filter TimeDiff < 20
https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/datetime-difffunction