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!

Aligning Observability Costs with Business Value: Practical Strategies

 Join us for an engaging Tech Talk on Aligning Observability Costs with Business Value: Practical ...

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...

Splunk Up Your Game: Why It's Time to Embrace Python 3.9+ and OpenSSL 3.0

Did you know that for Splunk Enterprise 9.4, Python 3.9 is the default interpreter? This shift is not just a ...