Splunk Search

active user session at any given time

lain179
Communicator

Hi,

I would like to draw a chart representing number of active sessions at any given time...probably on a time chart.

The log contains three different type of log lines: Login, Log out and Expire sessions. I have come up with the following search so far, but it's not working well.


sourcetype="Engine" Server="ABC" login OR "log out" OR "removing session" | transaction UserSession | where duration=0 | timechart span=1m count(LoginDate) as in count(LogoutDate) as out count(LoginExpireDate) as expire | streamstats sum(in) as totalin sum(out) as totalout sum(expire) as totalexpire | eval totalactive=totalin-totalout-totalexpire 

Thanks.

Tags (2)
0 Karma

takeda
Engager

Hi,

Why do you filter the result of transaction command with duration=0?
I think that causes Splunk to return sessions that immediately end after they start.

Maybe "concurrency" command can be used for your purpose.
http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Concurrency

0 Karma

lain179
Communicator

Not true. If there is a duration, that mean the session has already started and ended and I don't need to count them because they are NOT active. Duration is measured in millisecond, so for any completed sessions, duration will be at least 1.

By filtering for duration = 0, I get three things:
- Login sessions that has not logout or expires yet
- logout session that has a login before the time range specified
- expired session that has a login before the time range specified

And no, concurrency is not what I need.

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!

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 ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...