Splunk Search

Pass fields from base search to subsearch fails

stwong
Communicator

Hi, I tried to do a base search, then pass fields to subsearch as both a filter and stat columns. I tested with following:

index="_internal" | eval MyUser=user | table MyUser bytes | map search="search index="_audit" user=$MyUser$ | stats values(user), values($MyUser$) as MyUser, values($bytes$) as bytes, values(action) "

user=$MyUser$ works but the columns for fields MyUser and bytes are empty.

Please help. Thanks.

Besides, will there be better and more efficient way to do so?

Thanks a lot.
/ST Wong

0 Karma

sundareshr
Legend

What are you trying to do? I don't believe there is a co-relation between user & bytes in _internal AND user & bytes in _audit. Try this search, is this what you're after?

(index=_internal OR index=_audit) | stats values(bytes) as bytes values(action) as actions dc(index) as idx by user | where idx=2
0 Karma

stwong
Communicator

Hi, thanks. I just try to do a base search, then pass fields to subsearch as both a filter and stat columns as mentioned. As i don't have much sample data for my trial splunk cloud instance, I just use _internal and _audit to verify the method, for learning the map function. Sorry to cause you confusion.

Thanks.

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi stwong,
I had this problem and I think that it's a bug.
I solved it with a workaround, inserting in the base search an eval command with the missed fields: e.g. | eval myfield=myfield
In this way I found the field also in the panel search.
Bye.
Giuseppe

0 Karma

stwong
Communicator

Hi Giuseppe,

Thanks, I modified my search as following but doesn't work still:

index="_internal" | eval MyUser=user | table MyUser bytes | eval MyUser=MyUser | eval bytes=bytes | map search="search index="_audit" user=$MyUser$ | stats values(user), values($MyUser$) as MyUser, values($bytes$) as bytes, values(action) "

shall I add the eval statement like that? Thanks again.

Get Updates on the Splunk Community!

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 ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...