Hi SecureIA,
Try something like this,
| stats latest(eval(if(status="loggedin",_time, null()))) as logon,
latest(eval(if(status="logout",_time, null()))) as logoff by <host, device, sessiond, msg_id>
| eval logoff=if(logoff<logon OR isnull(logoff), "Live",logoff))
| eval logon=if(isnull(logon,"Not in time Range",logon)
| eval duration=tostring(logoff-logon,"duration")
| eval logon=if(isint(logon),strftime(logon,"%+"), logon)
| eval logoff=if(isint(logoff),strftime(logoff,"%+"), logoff)
stats's by class i've mentioned some random fields, you can change based on your search. I guess remaining will help you,
Note: Assuming you have a field called status that can identify the even is logon or logoff. If not you can use the _raw to define. I prefer instead of checking raw extract a field and name it as status.
stauts="loggedin" => _raw like "%logged in%"
status="logout" => _raw like "%logged out%"
Thanks,
V
... View more