Splunk Search

Trying do not use a join

pierre_weg
Path Finder

Hi guys!

I have a static snapshot lookup that stores a lot of information about vulnerabilities actives on my hosts in mar/01.

This SPL shows me a full list of the unique identifiers.

| inputlookup gvul:collectMar.csv | table UniqID

 

This SPL shows me a list of the unique identifiers actives today

earlyest=-1d index=myindex sourcetype=mysourcetype | table UniqID 

 

My team works to fix this vulnerabilities, so I want a timechart to show the work progress, based on the snapshot lookup. I don care about new vulnerabilities since the snapshot.

This is the SPL that I'm using to do this.

earliest=1677719215 index=myindex sourcetype=mysourcetype | join type=inner UniqID [ | inputlookup gvul:collectMar.csv | table UniqID] | timechart span=1d count(UniqID)

 

So, is there a way to do this but not using a join statement?

Labels (1)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

If you want to limit your search to just the values included in the lookup, there are (at least) two different techniques that can be used.

1) As @gcusello showed - you can use a subsearch to generate a set of conditions which will be passed to the outer search limiting the result set.

2) Use lookup directly to filter the results from the main search

<your_search>
| lookup gvul:collectMar.csv UniqID OUTPUT UniqID
| search UniqID=*

The trick here is that if there is no matching UniqID in the lookup file the lookup command will set this value to null so you can filter out the events which do not contain this field.

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @pierre_weg ,

in general you can use the lookup command (https://docs.splunk.com/Documentation/Splunk/9.1.0/SearchReference/Lookup)  that's like a left join.

But let me understand: you need to filter results using the lookup to have the distribution of events with the UniqID from the table, is it correct?

if this is your requirement, you could try something like this:

earliest=1677719215 index=myindex sourcetype=mysourcetype [ | inputlookup gvul:collectMar.csv | table UniqID] 
| timechart span=1d count(UniqID)

 Ciao.

Giuseppe

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!

Persistent Queue at TcpOut — One of Splunk's Most Practical Features

Splunk introduced persistent queueing at the tcpout layer as one of the most practical resilience features in ...

Skip the Awkward Silence: Have a .conf-ersation at .conf26

Picture this. You arrive at .conf26 already having your socializing and networking plans mapped out. No ...

Rethinking Zero Trust: From Product Purchases to Logical Control Evidence

Implementing Zero Trust (ZT) across complex environments often falters at the very beginning due to a ...