Splunk Search

how to join 2 different searches in a single index with different fileds and mapping them to the common field

balavenkatachal
New Member

how to join 2 different searches in a single index with different fileds and mapping them to the common field, please help :

My Problem Statement :

  1. I have a string string "Participant_System_Information" on the index = broker and i want to get the count and percentage of OSType and i use the below query and i get the result.

sourcetype="broker" host="g2m*" Participant_System_Information| top OSType

Result :

OSType count percent

Windows 45741 90.932766
MacOSX 4176 8.301857
iOS 385 0.765377

  1. I have a string string "createUpdateAttendeeResource" on the index = broker and i want to get the count and percentage of ClientName as i don't have the OSTYpe Filed and i get the result.

sourcetype="broker" host="g2m*" createUpdateAttendeeResource| top ClientName

ClientName count percent

android 193 100.000000

Now i want to combine the above 2 quries and get the combined result of OSType and i used the below query and i am not getting the accurate count :

sourcetype="broker" host="g2m*" (createUpdateAttendeeResource OR Participant_System_Information)|rename OSType as OS| rename ClientName as OS| top OS

OS count percent

Windows 483 67.458101
android 177 24.720670
MacOSX 56 7.821229

I think for some reason "rename" is not working as expected when combing the query, please help.

Tags (1)
0 Karma

balavenkatachal
New Member

Great , this seem to give the count that matches.
Thanks a lot !

0 Karma

lguinn2
Legend

I think that the last rename is always overwriting the previous value of the OS field and so you are losing information. Try this:

sourcetype="broker" host="g2m*" (createUpdateAttendeeResource OR Participant_System_Information) | 
rename OSType as OS | 
eval OS = if(OS=="" or isnull(OS),ClientName,OS) | 
top OS
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 ...