I'm looking for a timestamp of specific error in a log and so I can identify which other events occurred within N seconds of it in other tables.
I'm able to construct a table (set) of datetime intervals/windows, but I'm struggling to determine when a datetime from another table occurs within any of the intervals in the set.
// Create a table of time windows (interval) +/- 5 seconds of target error
let intervals = k8slogs
| where Message contains "my specific error"
| project begin=datetime_add('second', -5, env_time), end=datetime_add('second', 5, env_time)
// Show all messages within 5 seconds of "my specific error"
k8slogs
| union logs1
| union logs2
| where env_time // is in any 'window' from above query
| project env_time, Message
| order by env_time asc
I also tried looking into the around() function, but wasn't able to come up with a solution.
Here is another example below with sample data:
k8slogs
| env_time | message |
|:-------- |:----------------------- |
| 15 | "my specific exception" |
| 45 | "my specific exception" |
logs1
| env_time | message |
|:-------- |:----------------------- |
| 11 | "another error" |
| 35 | "hello world" |
intervals
| begin | end |
|:----- |:------:|
| 10 | 20 |
| 40 | 50 |
desired query result
| env_time | message |
|:-------- |:----------------------- |
| 11 | "another error" |
| 15 | "my specific exception" |
| 45 | "my specific exception" |