Splunk Search

Why am I getting different results with filtering and using the append command?

Gchouane
Engager

Hello ,
I would like to generate a customer analysis.

I must use order and a customer segmentation.

I write a search with one customer:
Search1 :

index=order sourcetype="order" id_customer=1780186  
| append [| search index=segmentation id_customer=1780186   | eval capacity=1 | table id_customer, segment , capacity]
| search id_customer=1780186 
| table id_customer, segment ,id_market_order

It returns customer order list and segmentation. (225 lines)

If I remove all filter , the new search returns 224 lines (just order list).
Search 2 :

index=order sourcetype="order"  
| append [| search index=segmentation  | eval capacity=1 | table id_customer, segment , capacity]
| search id_customer=1780186 
| table id_customer, segment ,id_market_order

If I add filter, the search 3 returns 225 lines.
Search 3 :

index=order sourcetype="order" id_customer=1780186  
| append [| search index=segmentation  | eval capacity=1 | table id_customer, segment , capacity]
| search id_customer=1780186 
| table id_customer, segment ,id_market_order

Have you an idea?

Thanks you.

Tags (3)
1 Solution

lguinn2
Legend

There is a default maximum number of events that can be returned from a subsearch. If you look at the search job inspector after running search #2, I think you may find that you have exceeded the maximum and therefore have lost one of your results.

However, this search dos not need a subsearch at all. This will work and be much faster:

id_customer=1780186 (index=order sourcetype="order") OR index=segmentation 
| table id_customer, segment, id_market_order

If you want to ensure that the order data precedes the segmentation data in the resulting table, you can do this

id_customer=1780186 (index=order sourcetype="order") OR index=segmentation 
| eval sequence=if(index=="order",1,2)    
| sort id_customer, sequence, _time
| table id_customer, segment, id_market_order

View solution in original post

lguinn2
Legend

There is a default maximum number of events that can be returned from a subsearch. If you look at the search job inspector after running search #2, I think you may find that you have exceeded the maximum and therefore have lost one of your results.

However, this search dos not need a subsearch at all. This will work and be much faster:

id_customer=1780186 (index=order sourcetype="order") OR index=segmentation 
| table id_customer, segment, id_market_order

If you want to ensure that the order data precedes the segmentation data in the resulting table, you can do this

id_customer=1780186 (index=order sourcetype="order") OR index=segmentation 
| eval sequence=if(index=="order",1,2)    
| sort id_customer, sequence, _time
| table id_customer, segment, id_market_order
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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

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 ...