Splunk Search

How to retrieve current user in splunk?

ngatchasandra
Builder

I want to retrieve a current user in splunk web by run a query.

thanks!

Tags (1)
0 Karma
1 Solution

gfuente
Motivator

Hello

You can use this query to see logged users in splunk web:

| rest /services/authentication/httpauth-tokens | search (NOT userName="splunk-system-user") searchId="" 
 | table userName splunk_server timeAccessed |join type=left userName [| rest /services/authentication/users splunk_server=local 
 |fields title roles realname|rename title as userName|rename realname as Name]
 |rename userName as User |rename splunk_server as "Splunk Server"|rename timeAccessed as "Time Accessed"|rename roles as Role
 |table User,"Splunk Server",Name,Role

Regards

View solution in original post

gfuente
Motivator

Then you can use this:

http://answers.splunk.com/answers/28633/current-user-in-search.html

 rest /services/authentication/current-context/context | fields + username

Regards

0 Karma

ngatchasandra
Builder

thanks for your time .
How do i do to get only the current User.

0 Karma

gfuente
Motivator

Hello

You can use this query to see logged users in splunk web:

| rest /services/authentication/httpauth-tokens | search (NOT userName="splunk-system-user") searchId="" 
 | table userName splunk_server timeAccessed |join type=left userName [| rest /services/authentication/users splunk_server=local 
 |fields title roles realname|rename title as userName|rename realname as Name]
 |rename userName as User |rename splunk_server as "Splunk Server"|rename timeAccessed as "Time Accessed"|rename roles as Role
 |table User,"Splunk Server",Name,Role

Regards

Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...