Splunk Search

How do I edit my search to create a distribution graph to show total session times for VPN connections?

soniquella
Path Finder

Good afternoon.

Please forgive my ignorance. I have been 'splunking' now for a few weeks and I am still very much learning as I go.

I have been tasked with creating a distribution graph that shows X-axis would be total session time and Y-axis would be the count of sessions that have that session time. Currently I have managed to extract the shown fields using rex, but I am unsure of how to progress. I guess using the existing fields ctime and dtime, I need to create a field session_time, but I am not sure how to do this?

...| eval ctime,dtime = session_time fails (perhaps obviously). 

host=********* sourcetype="WinEventLog:System" EventCode=20272 SourceName=RemoteAccess | rex field=Message ": The user (?<user>\S+) connected on port (?<port>\S+) on (?<cdate>\S+) at (?<ctime>\S+) and disconnected on (?<ddate>\S+) at (?<dtime>\S+).*?active for (?<cmins>\d+) minutes (?<csecs>\d+) seconds" 

Any advice or assistance would be greatly appreciated.

Kind regards,

Rob.

0 Karma
1 Solution

lguinn2
Legend

The following should work

host=* sourcetype="WinEventLog:System" EventCode=20272 SourceName=RemoteAccess 
| rex field=Message ": The user (?<user>\S+) connected on port (?<port>\S+) on (?<cdate>\S+) at (?<ctime>\S+) and disconnected on (?<ddate>\S+) at (?<dtime>\S+).*? active for (?<cmins>\d+) minutes (?<csecs>\d+) seconds"
| eval session_time = cmins*60 + csecs
| stats count by session_time

However, the session time is calculated down to the second - you might want to group the sessions by minute instead...

View solution in original post

0 Karma

lguinn2
Legend

The following should work

host=* sourcetype="WinEventLog:System" EventCode=20272 SourceName=RemoteAccess 
| rex field=Message ": The user (?<user>\S+) connected on port (?<port>\S+) on (?<cdate>\S+) at (?<ctime>\S+) and disconnected on (?<ddate>\S+) at (?<dtime>\S+).*? active for (?<cmins>\d+) minutes (?<csecs>\d+) seconds"
| eval session_time = cmins*60 + csecs
| stats count by session_time

However, the session time is calculated down to the second - you might want to group the sessions by minute instead...

0 Karma

soniquella
Path Finder

Thank you so much for your answer.

0 Karma

soniquella
Path Finder

I guess I now need to learn about buckets to set suitable time spans. I do really appreciate your assistance with this.

0 Karma

lguinn2
Legend

If you just did

| eval session_time = cmins

You would already be grouping the session time by minutes instead of seconds.

0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...