Splunk Search

IP address of current user?

matstap
Communicator

I'm trying to write a query to display the IP address of the current user. Anyone know how to do this?

0 Karma
1 Solution

elliotproebstel
Champion

Depending on your infrastructure, the following may work:

index=_internal sourcetype=splunkd_ui_access 
    [| rest /services/authentication/current-context splunk_server=local 
    | stats values(username) AS search 
    | format ] 
| head 1 
| stats list(clientip) AS clientip

The subsearch will return the username of the user who is currently logged in. It uses that to search across splunkd_ui_access logs and extracts the clientip from the latest matching one.

However, this doesn't work at all on my system, because we have a proxy on our Splunk server, which means this returns 127.0.0.1 for every user. 🙂 So your mileage may vary.

View solution in original post

elliotproebstel
Champion

Depending on your infrastructure, the following may work:

index=_internal sourcetype=splunkd_ui_access 
    [| rest /services/authentication/current-context splunk_server=local 
    | stats values(username) AS search 
    | format ] 
| head 1 
| stats list(clientip) AS clientip

The subsearch will return the username of the user who is currently logged in. It uses that to search across splunkd_ui_access logs and extracts the clientip from the latest matching one.

However, this doesn't work at all on my system, because we have a proxy on our Splunk server, which means this returns 127.0.0.1 for every user. 🙂 So your mileage may vary.

skoelpin
SplunkTrust
SplunkTrust

We're going to need more information than that..

Are your events logging in Splunk? Did you have a field that captures the IP addresses? Do you have a field or lookup table of users? You want the current users IP address who's logged into Splunk? And lastly, ofcourse we know how to do this.. You provide the correct information and we provide the correct solution 🙂

0 Karma

somesoni2
Revered Legend

Current user using Splunk Web UI (trying to display from user logged in from)?

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...