Splunk Search

Combining two searches for purpose of table & stats

Barty
Explorer

Good afternoon all,

Apologies for the below, my first question and also I'm a complete newbie to this. So, I have been asked by a user if it would be possible to combine two searches for the purpose of creating a table that has the resulting fields and also a stats count on one of the fields.

Let me explain. The two base searches are:-

Search 1:

index=our_index "Initialising journeyContext using initial request parameters:[AggregatorInitialRequest{aggregatorID" source="/user_projects/domains/gidprd/servers/qbp-*/logs/qnb-application-log/car-qnb-application.M6.log"
| rex "\[[^\:]*\:(?<sessionId>.*)\:\:\:M6.*aggregatorID\=\'(?<aggId>[^\']*)"
| table sessionId aggId

Search 2

index=our_index source="/user_projects/domains/gidprd/servers/qbp-*/logs/qnb-application-log/car-qnb-application.M6.log" 
| rex "\[[^\:]*\:(?<sessionId>[^\:]*)\:(?<requestId>[^\:]*)" 
| dedup requestId 
| stats count as counter by sessionId

What the end user would like is a table that has sessionId | aggId | count

Now I have played around trying to use the join command on sessionId, but to no avail and it's absolutely killing me. I've got as far as trying this, but no results are returning:-

index=our_index "Initialising journeyContext using initial request parameters:[AggregatorInitialRequest{aggregatorID" source="/user_projects/domains/gidprd/servers/qbp-*/logs/qnb-application-log/car-qnb-application.M6.log"
| rex "\[[^\:]*\:(?<sessionId>.*)\:\:\:M6.*aggregatorID\=\'(?<aggId>[^\']*)"
| join sessionId 
    [search index=app_qnb earliest=-10m source="/user_projects/domains/gidprd/servers/qbp-*/logs/qnb-application-log/car-qnb-application.M6.log" | rex "\[[^\:]*\:(?<sessionId>[^\:]*)\:(?<requestId>[^\:]*)"]
| table sessionId

I was hoping i could at leats get as far as the combination of both sessionId results, but no such luck. I'm turning to you guys as I know someone out there is going to hopefully show how to do this quickly, easily and far less complicated than I am making it! Oh, and it's v6.6.4 if that helps.

Help me Obi-splunk_kenobi, you're my only hope

0 Karma
1 Solution

somesoni2
Revered Legend

Give this a try..

 index=our_index source="/user_projects/domains/gidprd/servers/qbp-*/logs/qnb-application-log/car-qnb-application.M6.log"
| rex "\[[^\:]*\:(?<sessionId>[^\:]*)"
| rex "\[[^\:]*\:(.*)\:\:\:M6.*aggregatorID\=\'(?<aggId>[^\']*)"
| rex "\[[^\:]*\:([^\:]*)\:(?<requestId>[^\:]*)" 
| stats values(aggId) as aggId dc(requestId) as counter by sessionId

View solution in original post

0 Karma

Barty
Explorer

Seems to have worked a charm! Thank you

0 Karma

somesoni2
Revered Legend

Give this a try..

 index=our_index source="/user_projects/domains/gidprd/servers/qbp-*/logs/qnb-application-log/car-qnb-application.M6.log"
| rex "\[[^\:]*\:(?<sessionId>[^\:]*)"
| rex "\[[^\:]*\:(.*)\:\:\:M6.*aggregatorID\=\'(?<aggId>[^\']*)"
| rex "\[[^\:]*\:([^\:]*)\:(?<requestId>[^\:]*)" 
| stats values(aggId) as aggId dc(requestId) as counter by sessionId
0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...