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!

CX Day is Coming!

Customer Experience (CX) Day is on October 7th!! We're so excited to bring back another day full of wonderful ...

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...