Splunk Search

How to join or search fields from two different indexes with a common field

vnguyen46
Contributor

Hi,
I have two indexes basically like this:
indexA has field1, field2, field3
indexB has field4, field5, field6
field1=field4 (both are username)
I need a table showing:
field1, field2, field5, field6

In SQL, I can use join query, but I don't know how in SPL. Thank you for your help.

1 Solution

iamsplunker31
Path Finder

You can try something like this

index=indexA OR indexB |table field1,field2,field5,field6

View solution in original post

vnguyen46
Contributor

Thanks for reply.

Actually, I learned from other post and used this:
indexA sourcetype...| rename field1 AS field | table field1, field2
| join field
[search indexB sourcetype...| rename field4 AS field | table field5, field6]

It works well.
Thanks again.

iamsplunker31
Path Finder

You can try something like this

index=indexA OR indexB |table field1,field2,field5,field6

Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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