Splunk Search

Combine 2 searches that have a subsearch

ludowillemans
Explorer

I want to get all events related to dnis=27159866
I can perform this by getting all the events with a sessionid or parentsessionid linked to the dnis=27159866

I have the following searches :

  1. to get all events with a sessionid linked to the dnis=27159866
    The subsearch will get all sessionid linked to dnis=27159866 and then the search looks for all events with those sessionid's.

    sourcetype=vxml [search dnis=27159866 | fields sessionid]

  2. to get all events with a parentsessionid linked to the dnis=27159866
    The subsearch will get all sessionid linked to dnis=27159866, put it in the parentsessionid field and then the search looks for all events with those parentsessionid's.

    sourcetype=vxml [search dnis=27159866 | eval parentsessionid=sessionid | fields parentsessionid]

How can I combine those 2 searches in one search ?
So events where sessionid OR parentsessionid is equal to a value returned from the subsearch.

0 Karma
1 Solution

tom_frotscher
Builder

is it correct, that both of your subsearches have the same results? The only difference i can see is that in the first subsearch everything you return is stored in the field called sessionid and in the second subsearch you retrieve the same results but rename it to parentsessionid?

Isn't it possible to combine this to something like this:

sourcetype=vxml [search dnis=27159866 | eval parentsessionid=sessionid | fields sessionid parentsessionid]

It might be possible that you have to play around with the format command, to ensure that the results of your subsearch are concatenated as ((sessionid=123 OR parentsessionid=123) OR (sessionid=345 OR parentsessionid=345)...).

View solution in original post

tom_frotscher
Builder

is it correct, that both of your subsearches have the same results? The only difference i can see is that in the first subsearch everything you return is stored in the field called sessionid and in the second subsearch you retrieve the same results but rename it to parentsessionid?

Isn't it possible to combine this to something like this:

sourcetype=vxml [search dnis=27159866 | eval parentsessionid=sessionid | fields sessionid parentsessionid]

It might be possible that you have to play around with the format command, to ensure that the results of your subsearch are concatenated as ((sessionid=123 OR parentsessionid=123) OR (sessionid=345 OR parentsessionid=345)...).

ludowillemans
Explorer

yes, I added the format and I get the result that i wanted.

sourcetype=vxml [search dnis=27159866 | eval parentsessionid=sessionid | fields sessionid parentsessionid
| format "(" "(" "OR" ")" "OR" ")"]

richgalloway
SplunkTrust
SplunkTrust

If this solves your problem, please convert the comment to an answer and accept it. This will help others with similar problems in the future.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...