Splunk Search

append or multi search

eus_e2e_enginee
Engager

Trying to make search more efficient.  Any tips? Would multi search work more efficiently?

index=<myindex> sourcetype="cisco_cdr" duration > 0 earliest=-1d@d latest=@d
| rename callingPartyUnicodeLoginUserID AS SID
| where match(SID, "[A-Za-z]\d{6}")
| eval Calls_Made_cob_date = strftime(_time, "%Y-%m-%d") ,Day=strftime(_time,"%a"),Date=strftime(_time, "%Y-%m-%d")
| stats count as Calls_Made sum(duration) as Calls_Made_Duration by Date Day SID
| append
[| search index=<myindex> sourcetype="cisco_cdr" duration > 0
earliest=-1d@d latest=@d
| rename finalCalledPartyUnicodeLoginUserID AS SID
| where match(SID, "[A-Za-z]\d{6}")
| eval Calls_Received_cob_date = strftime(_time, "%Y-%m-%d") ,Day=strftime(_time,"%a"),Date=strftime(_time, "%Y-%m-%d")
| stats count as Calls_Received sum(duration) as Calls_Received_Duration by Date Day SID ]
| stats values(*) as * by Date Day SID
| fillnull value="0"
| eval Total_Duration=(Calls_Made_Duration+Calls_Received_Duration)
| where Total_Duration > 0
| table SID Date Day Calls_Made Calls_Made_Duration Calls_Received Calls_Received_Duration Total_Duration

Labels (2)
0 Karma

efavreau
Motivator

@eus_e2e_engineeI'm not seeing a need for the append or the second search, as everything before the first pipe in both searches is the same. If there's no case, then that is indeed inefficient. Collect everything up front and then categorize away using evals.

What you may be running into, is a filtering out of fields due to the stats command. If that's the case, I'd look into using eventstats and/or streamstats instead of stats. There's an old but relevant blog post here about those: https://www.splunk.com/en_us/blog/tips-and-tricks/search-command-stats-eventstats-and-streamstats-2....

###

If this reply helps you, an upvote would be appreciated.

###

If this reply helps you, an upvote would be appreciated.

richgalloway
SplunkTrust
SplunkTrust
Use multisearch. It runs both subsearches in parallel and is not subject to the same limitations as append.
---
If this reply helps you, Karma would be appreciated.
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...