How to eliminate duplicate rows before transaction command. Because of which I am getting wrong calculation. eg scenario: calculating downtime based on events Query is
index="wineven...
See more...
How to eliminate duplicate rows before transaction command. Because of which I am getting wrong calculation. eg scenario: calculating downtime based on events Query is
index="winevent" host IN (abc) EventCode=6006 OR EventCode="6005" Type=Information
| eval BootUptime = if(EventCode=6005,strftime(_time, "%Y-%d-%m %H:%M:%S"),null())
| eval stoptime = if(EventCode=6006,strftime(_time, "%Y-%d-%m %H:%M:%S"),null())
| transaction host startswith=6006 endswith=6005 maxevents=2
| eval duration=tostring(duration,"duration")
| eval time_taken = replace(duration,"(\d+)\:(\d+)\:(\d+)","\1h \2min \3sec")
| rename time_taken AS Downtime
| dedup Downtime, BootUptime
| table host,stoptime, BootUptime, Downtime
Result is ::
host stoptime bootuptime Downtime
abc 2022-30-01 10:39:25 2022-30-01 10:40:29 00h 01min 04sec
abc 2022-09-01 09:27:53 2022-09-01 09:28:34 00h 00min 41sec
abc 2021-28-11 10:52:52 2022-09-01 09:28:34 41d 22h 35min 42sec
in the result since i have duplicate in bootuptime the dowtime calculation is incorrect. How to get rid of this? Thanks in Advance