Splunk Search

Extend search results data by correlation-id (and exclude on other messages)

sscholl
Engager

Hello, I have 500 HTTP messages in my access log. Also I have corresponding events from other log sources with the same correlation-id. Now I want to join the information to enhance the results.

 

Access Log Events:

 

2024-04-25T11:00:26+00:00 [info] type=access  status=500 xCorrelationId=90e2a321-f522-466f-9ffa-72cbdaa1a576 ....

2024-04-25T10:15:25+00:00 [info] type=access status=500 xCorrelationId=9b1833f5-776b-44c3-92d7-d603abdfecf8 ...

 

Other Events:

 

2024-04-25T10:15:24+00:00 xCorrelationId=9b1833f5-776b-44c3-92d7-d603abdfecf8  NoHandlerFoundException: No endpoint GET

 

 

My actual intention is, to exclude the results from main search, if there is another event with the same correlation-id but containing specific exceptions like "NoHandlerFoundException". That means, i need a search per result from the main search.

Do you know a solution for this?

Thanks!

Labels (1)
Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
<main index> NOT [search <other source> NoHandlerFoundException | stats count by xCorrelationId | fields xCorrelationId | format]

However, depending on how may exceptions you have, you may run into limitations as the sub-search with the format command will essentially return a long string which might be too large to be parsed in the main search.

Another way to do it is to search both sources, and correlate by xCorrelationId and exclude those xCorrelationId's which have the exception, but this still means you are retrieving both full sets of events and correlating them before you can filter out any.

bowesmana
SplunkTrust
SplunkTrust

The number of values in the subsearch cannot be too large as it will perform really badly, but one slight change to @ITWhisperer subsearch is to do

<main index> NOT [
    search <other source> NoHandlerFoundException 
    | stats values(xCorrelationId) as search
    | format]

which will perform faster. It will change the outer search from

<main index> NOT ( ( ( xCorrelationId=A OR xCorrelationId=B OR... ) ) )

to

<main index> NOT ( ( ( A OR B OR C OR D ... ) ) )

where A, B etc are the values or xCorrelationId

The key point is having a field name 'search' in the output rather than xCorrelationId, which changes the effect of the format command.

Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...