Splunk Search

Append search filtering in the second search by a field of the first one

rodkinal
New Member

Hello,

I'm trying to append a search to my principal search by filtering the second search using a field of the first one. Let me explain myself better.

My first search has different fields:index=machines environment=production | table ip, domain-name, last-update, application

ip,       domain-name,   last-update,     application
10.0.0.1, machine_A,     1/1/2018,        mysql
10.0.0.2, machine_B,     1/2/2018,        apache2
10.1.1.4, machine _4000, 4/5/2018,        smb-server

My second search has other fields: index=admin environment=administrator | table administrator, os-system, domain-name, last-connection

administrator, os-system,   domain-name,   last-connection
admin1, linux, machine_A, 1/1/2017
admin2, linux, machine_B, 1/2/2017
admin3, windows, machine _4000, 4/5/2017

I would like to merge both table using the domain-name of the first search. I would like to use the field domain-name of the first search to lookup on the second one for it's administrator and the OS so the result would look like this:

ip,       domain-name,   last-update,     application, administrator, os-system
10.0.0.1, machine_A, 1/1/2018, mysql admin1 linux
10.0.0.2, machine_B, 1/2/2018, apache2 admin2 linux
10.1.1.4, machine _4000, 4/5/2018, smb-server admin3 windows

I've tried using this search:

index=main environment=production | rename domain-name as domain-name_1 | append [search index=admin environment=administrator | rename domain-name as domain-name_2 ] | table ip, domain-name, last-update, application, administrator, os-system | where domain-name_1 = domain-name_2

I have also tried using join and other weird things like appendcols. It didn't work. The fields of the second search doesn't appear.

Can anyone help me please?

Thank you very much in advance!! 😄

0 Karma
1 Solution

ansif
Motivator

Try this:

index=machines environment=production | join domain-name
[ search index=admin environment=administrator
| dedup domain-name]

View solution in original post

0 Karma

ansif
Motivator

Try this:

index=machines environment=production | join domain-name
[ search index=admin environment=administrator
| dedup domain-name]

0 Karma

amzar96
Explorer

Hi @ansif , let say in this situation

I have different domain-name

table 1: domain-name-a
table 2: domain-name-b

then, how can I do to join the both query? Thanks

0 Karma

rodkinal
New Member

This worked for me!! I didn't release about the join command!

Kind regards! 🙂

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!

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

Index This | How many sevens are there between 1 and 100?

August 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...