Splunk Search

How to do RIGHT OUTER JOIN with Lookup table?

pm771
Communicator

Events stream has ID field in every record.  

There is a lookup table with a small subset of IDs.

The task is to calculate the total number of occurrences for each ID from the lookup table for every 15 min.

It is possible that certain IDs from the table will not be found.  In such cases they should still be included in the result with the count of zero.

SQL version:

SELECT ID, COUNT(ID)  
FROM Events e
RIGHT JOIN Lookup l ON l.ID=e.ID
GROUP BY I.ID 

What would be a good Splunk way to achieve the same?

Labels (3)
0 Karma

renjith_nair
Legend

@pm771,

One of the approaches is

Assuming you have a lookup "ID" with set of "ids"

|inputlookup ID|eval count=0, source="lookup"
|append [search index="your index" | stats count by ids|eval source="events" ]
|stats sum(count) as count,values(source) as source by ids

Source is added to distinguish between the sources , you may remove it

If the result looks good, we shall further filter it by using the source

---
What goes around comes around. If it helps, hit it with Karma 🙂

pm771
Communicator

@renjith_nair ,

Thank you very much for your reply.

I was considering  an`append` approach but did not come with `count()` and `sum()` combination.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

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

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...