Splunk Search

How to get a count of active transactions to visualize in timechart?

giovere
Path Finder

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?

alt text

| transaction UserId startswith="login" endswith="logout" | timechart count by UserId
| transaction UserId startswith="login" endswith="logout" | timechart count

Thanks in advance

0 Karma

rafaelsalazar
Path Finder

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.

pabstec
New Member

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

0 Karma

jeffland
SplunkTrust
SplunkTrust

I think you want to count the concurrency of your transactions.

giovere
Path Finder

YES! that is exactly what I'm trying to do, still having troubles get it working with gentimes, eval, append and concurrency, lacking some experience.

0 Karma

chimell
Motivator

Hi giovere
Try this search code And let me known if it work like you want

........| transaction UserId startswith="login" endswith="logout" | timechart  span=1h count by UserId
0 Karma

giovere
Path Finder

hello Chimell
Your solution has the same limitation as Schose's. It charts only start time of the transaction.

0 Karma

schose
Builder

Hi,

 | transaction UserId startswith="login" endswith="logout" | 
concurrency duration=duration | 
timechart max(concurrency)

... should do the job.

Cheers,

Andreas

0 Karma

giovere
Path Finder

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.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...