Splunk Search

Using subsearches to narrow down main search to a specific source

anz_leycurav
Explorer

Hi,

Say I'm collecting crash reports into log A (I'm extracting the PID using rex) and the activity leading to said crash I am collecting into log B of another sourcetype. The only way to correlate both is through the PID BUT the twist is that log B _raw does not contain it, the source does. For example:

log A detects crash of session 123
I want to see all events logged into logB_123.log

I would expect the subsearch part to be giving the crash side (log A) but how do i relate this to the main search, in order to direct it to look a specific source using a number I got from log A?

Thanks Vincent.

Tags (1)
0 Karma

martin_mueller
SplunkTrust
SplunkTrust

You can extract the PID from the source field, using rex it'd look like this:

sourcetype=B | rex field=source "_(?<PID>\d+)\.log" | ...

Note, filtering on this will be slow because Splunk has to load everything from B, extract the PID, and then throw out most of the loaded data. It'll be faster if you specify the PID extraction through props.conf like this:

[B]
EXTRACT-PIDinsource = _(?<PID>\d+)\.log in source
0 Karma

martin_mueller
SplunkTrust
SplunkTrust

You can do that once you have a PID field in sourcetype B extracted like shown above.

sourcetype=B [search sourcetype=A some magic filter | dedup PID | fields PID]

The subsearch evaluates to an OR'd list of PID=1234 filters, which are applied against your configured EXTRACT-PIDinsource.

0 Karma

anz_leycurav
Explorer

Thanks Martin, but what I'm after is presenting the events within log B.

Literally I want my search to run like "give me the full list of events found in source X, where the X string contains the PID that's obtained from log A"

Thanks again Vincent.

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...