Splunk Search

How to join two searches?

Shashank_87
Explorer

Hi, I am trying to join two of my searches in splunk using a common field uniqueID but I am getting a error in Splunk Job inspector - SubSearch produced more than 50k results, truncating to max out 50k.
I can't change limits.conf and I have to use the query to get the desired result.

Really appreciate if someone can help on this? My query is something like this -

index="A" sourcetype="test*" requested_content="/index" 
| join uniqueId
    [ search [search B] ] 
| timechart span=1h count 
Tags (2)
0 Karma
1 Solution

woodcock
Esteemed Legend

As others have mentioned, this is exactly why join should be avoided. Try this:

(index="A" sourcetype="test*" requested_content="/index") OR (search B with uniqueId)
| bin _time span=1h
| stats dc(sourcetype) AS num_sourcetypes values(sourcetype) BY uniqueId _time
| where num_sourcetypes==2 OR Maybe Different Logic HERE
| timechart span=1h count

View solution in original post

0 Karma

woodcock
Esteemed Legend

As others have mentioned, this is exactly why join should be avoided. Try this:

(index="A" sourcetype="test*" requested_content="/index") OR (search B with uniqueId)
| bin _time span=1h
| stats dc(sourcetype) AS num_sourcetypes values(sourcetype) BY uniqueId _time
| where num_sourcetypes==2 OR Maybe Different Logic HERE
| timechart span=1h count
0 Karma

renjith_nair
Legend

Hi @Shashank_87,

Try adding format to the subsearch

index="A" sourcetype="test*" requested_content="/index" 
| join uniqueId
[ search [search B|format] ] 
| timechart span=1h count 

Also if you have a common unique field, try

index="A" OR index="B"  requested_content="/index"  //Add your common search terms from both searches
|eventstats count(uniqueId)  as dups
|where dups >1
|timechart span=1h count 

If there is only one uniqueId in each event, above result will have duplicates only if its present in both searches and thus we can filter the results which have entries in both searches
If the above doesnt work, provide us some sample from both searches

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

Sukisen1981
Champion

Hi, there is always a limitation set on the number of rows you can run your join command with,
Typically your solunk admin would have set a limit of 50k (we have 25 k) as a threshold.
You need to tell us your use case and let us see if we can do this without a join / join with some trimming.
Needless to say, running such a big join will sooner or later give you severe performance issues.

0 Karma

Shashank_87
Explorer

so I am looking to get the response time for a particular page. Now that pages comes in both logged in and logged out versions and I am only looking for logged in customers.
My search 1 gives the page load time (response_time) of the requested content but it doesn't tell you if it was logged out page or logged in page. My 2nd search gives me the events which will only come in case of Logged in customer.
So I need to join two searches on the basis of a common field called uniqueID.

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!

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

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...