Splunk Search

I want to insert a value into a subsearch using the search result as a variable.

Msugiyama
Path Finder

Dear ALL,

I want to insert a value into a subsearch using the search result as a variable.

Do the following search to get your own username
Is there a way to search again with my username?

=========================================

| rest / services / authentication / current-context
| table realname

=========================================

rlaname
------------------------------------------
M_sugiyama                               ← Use this value as a variable

=========================================

index=AD "M_sugiyama"      ← I want to search by assigning variables to the next subsearch

=========================================

Do you have a good idea?

Labels (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Recall that subsearches execute before the main search so the query to get the username must be the subsearch and that result is "passed" to the main search.

index=AD [| rest / services / authentication / current-context
| table realname]
---
If this reply helps you, Karma would be appreciated.

ITWhisperer
SplunkTrust
SplunkTrust

If the value exists in a field in the second search, you can do something like this

index=AD 
| search [| rest /services/authentication/current-context
| table realname
| rename realname as rlaname]

If that doesn't work, there are other things you could try

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...