Splunk Search

Combine two columns in a table from two separate searches (where one is a subset of the other)

splunkuser2127
Loves-to-Learn

I'm currently running the query (changed to a dog-themed query) where I want to join two logs together by the Dog's name and end up getting the dog's id:

search "something within logs" | join dog_name_field [search "Dogs Name: "]| table "dog_id"

I want another column in the table, which is a subset of the results of the above search, where I get a true or false on whether or not that id belongs to a Golden Retriever. To get the id's for the golden retrievers, I can do something like:

search "something within logs" | join dog_name_field[search "Dogs Name: " AND "Golden Retriever"]| table "dog_id"

How do I get the ids of all the dogs and have another column saying whether or not that dogs is a golden retriever efficiently.

Tags (2)
0 Karma

renjith_nair
Legend

@splunkuser2127 ,

If the dog name is a common field in both searches , try below

Let's say search1 includes index1 and search2 includes index2

index=1 OR index=2 |stats values(dog_id) as dog_id , dc(index) as count by dogs_name
|where count >1

This should give you the common records from both search

Add additional field

    index=1 OR index=2 |stats values(dog_id) as dog_id , dc(index) as count by dogs_name
    |where count >1
    |eval  is_golden_retriever=if(dogs_name=="Golden Retriever","True","False")
---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma

splunkuser2127
Loves-to-Learn

This is helpful, but the dog_name can't be golden retriever, the word "Golden retriever" just might be found in the second search's log

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

.conf25 Global Broadcast: Don’t Miss a Moment

Hello Splunkers, .conf25 is only a click away.  Not able to make it to .conf25 in person? No worries, you can ...

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...