Splunk Search

How to Merge two query resultsets?

runiyal
Path Finder

I have two Searches and following are its result individually -

index="myindex" <my search 1> | table App Size Count

App  Size  Count
App1 5GB   100
App2 100GB 10000

index=myindex" <my search 2> | table App Size Count

App  Size Count
App3 15GB 1500

Now I want to run a report that shows result of all Apps (1 to 3) together. So, I used append.

index="myindex" <my search 1> | table App Size Count
| append
[search index=myindex" <my search 2> | table App Size Count]
| addcoltotals

But when I used it, I didn't get the complete result. "Size" column is showing different value. Something like this -

App  Size  Count
App1 5GB   100
App2 100GB 10000
App3 7GB   720

What should be used to get the complete resultset as we got for each search. Best way to merge two query resultsets.

 

Thanks!

Labels (2)
Tags (1)
0 Karma

runiyal
Path Finder

must be missing our something in the syntax but if I just use the OR between two searches like below I am getting Error in 'search' command: Unable to parse the search: unbalanced parentheses.

(<my search 1> OR <my search 2>)

 I have provided the complete search command above in reply to Renjith.

0 Karma

renjith_nair
Legend

You may try

index=myindex (search1 terms OR search2 terms) |table App,Size,Count|addcoltotals

splunk_search.jpg

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma

runiyal
Path Finder

Here is the updated Query which actual use of REX/EVAL/CASE/STATS in it:

(index="myindex" "*upload succeeded" OR "*streaming succeeded" NOT "source"
| rex ".*SIZE=(?<sizeKB>\d+\.\d+)" | stats sum(eval(sizeKB/1024/1024)) AS Size count | eval App="Upload-Manual")
OR
(index="myindex" "*upload succeeded" OR "*streaming succeeded"
| rex "source=(?<App>[^,]+)."
| rex "system=(?<App>[^,]+)." | eval App = case(App="FB","App1",App="TWTR","App2",App="Salesforce","App3",App="SAP","App3",App="Oracle","App3")
| rex ".*SIZE=(?<sizeKB>\d+\.\d+)" | stats sum(eval(sizeKB/1024/1024)) AS Size Count by App)
| table App Size Count
| addcoltotals

 

I am getting following error - 

Error in 'search' command: Unable to parse the search: unbalanced parentheses.

 

Thanks!

Tags (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @runiyal,

did you tried to put all the conditions in the main search?

something like this:

index="myindex" (<my search 1> OR <my search 2>)
| table App Size Count
| addcoltotals

Splunk isn't a DB!

Ciao.

Giuseppe

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...