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.

0 Karma

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
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...