I have a transactions defined by users logging in and out.
The Goal is to have a timechart showing count of active transactions at the end of an hour or 10 minutes (total and by user)
Any ideas how to get this?
| transaction UserId startswith="login" endswith="logout" | timechart count by UserId | transaction UserId startswith="login" endswith="logout" | timechart count
Thanks in advance
For those that came here (like me) in need for a solution, the trick I've found was to create mvfields with the span value and then mvexpand them and then do a distinct count by txid in the timechart..
So from original poster's question, lets assume we are there, and have duration in seconds created by the transaction command:
| transaction UserId startswith="login" endswith="logout"
Lets suppose that UserId is unique enough to be a TxId.
So we want to do a count of how many concurrent Tx's are at a particular timeslot of 1s:
| eval events=mvrange(0,duration,1) | fillnull events | mvexpand events
Now we have created on each event a # of lines with an increasing value of 1 from 0 to duration, and we are going to use that to offset each _time by that amount of seconds:
| eval _time=_time+events | timechart dc(UserId) span=1s
And finally we do a distinct count of the TxId.
In theory we should have and actual event per time slot to be able to to a timechart that counts active transactions by their duration.
I know that this doesn't directly answer the question your asking, but it is the closest I've found. Rather than visualizing the # of active transactions, I've visualized the "cost" of the transactions which translates to the sum of the durations where they show up by start time instead of end time.
...some search that includes duration in milliseconds...
| eval _time=_time-(duration/1000)
| timechart sum(duration) as durationSum
Thanks Andreas for the answer, your command returns for me the count of events only at the beginning of transaction. For example if I have a transaction starting at 9:00 lasting till 17:00 it would show only count 1 at 9:00 and rest is zero.