Splunk Search

How do I correlate across two log sources?

Splunk77
Explorer

I am writing a query to correlate across two different indexes. One index has userID field. I want the query to match a field in the second index and output additional fields from the second index.

index 'idx1' has field name usr. For the sake of this example, there is a user called 'jdoe'

index 'idx2' has a field name called user, which contains 'jdoe' along with another field called account ID, which has the name spelled out 'John Doe'. I want the query to use the usr field content from idx1 and use that info to pull the contents of 'account ID' field in index.

What's the best way to accomplish this?

Labels (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

You could do that with join or append, but that would be a waste of resources.  I simple disjunction will do.

(index=idx1 usr=*) OR (index=idx2 user=*)
``` Set the user field to user or usr, depending which exists in the event ```
| eval user = coalesce(user, usr)
``` Group events by user ```
| stats values(accountID) as accountID by user
| table user accountID
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

You could do that with join or append, but that would be a waste of resources.  I simple disjunction will do.

(index=idx1 usr=*) OR (index=idx2 user=*)
``` Set the user field to user or usr, depending which exists in the event ```
| eval user = coalesce(user, usr)
``` Group events by user ```
| stats values(accountID) as accountID by user
| table user accountID
---
If this reply helps you, Karma would be appreciated.
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 at Splunk .conf24 ...

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