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!

Enter the Dashboard Challenge and Watch the .conf24 Global Broadcast!

The Splunk Community Dashboard Challenge is still happening, and it's not too late to enter for the week of ...

Join Us at the Builder Bar at .conf24 – Empowering Innovation and Collaboration

What is the Builder Bar? The Builder Bar is more than just a place; it's a hub of creativity, collaboration, ...

Combine Multiline Logs into a Single Event with SOCK - a Guide for Advanced Users

This article is the continuation of the “Combine multiline logs into a single event with SOCK - a step-by-step ...