Put the following after your transaction:
| eval duration=if(eventcount==1, case(Event=="LOG_OFF", _time-relative_time(_time, "@d"), Event=="LOG_ON", relative_time(_time, "+1d@d")-_time), duration)
This does the following:
Checks if eventcount==1. If not, it uses the existing duration value.
If Event=="LOG_OFF" then it calculates the difference between the timestamp and the start of the day.
If Event=="LOG_ON" then it calculates the difference between the timestamp and the start of the next day.
That will allow transactions with a proper start/end to keep their transaction generated durations, while incomplete transactions will show durations according to your conditions. Then you should be able to do stats as expected.
... View more