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

Get Updates on the Splunk Community!

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...