Splunk Search

Compare query to lookup table but don't print if the results are in the lookup table.

hl
Path Finder
index=web
host!="*TEST*"
| rare limit=10 http_user_agent,c_ip,src,X_Forwarded_For,host
```|lookup static_assets ip as c_ip OUTPUT nt_host```
|table http_user_agent,c_ip,src_X_Forwarded_For,host,nt_host



I have a lookup table with three fields , 
 - category
- IP
- nt_host

I would like to compare the results from the search to the lookup table IP and nt_host and only print out the query that isn't in the lookup table. 

Labels (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

You have most of it already.  Just on nt_host.  If the value is null then it's not in the lookup.

index=web host!="*TEST*"
| rare limit=10 http_user_agent,c_ip,src,X_Forwarded_For,host
| lookup static_assets ip as c_ip OUTPUT nt_host
| where isnull(nt_host)
| table http_user_agent,c_ip,src_X_Forwarded_For,host,nt_host
---
If this reply helps you, Karma would be appreciated.

View solution in original post

hl
Path Finder

Ok so within a |where clause the nt_host does have to be actually "null" , null could mean don't use also? 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Null is not the same as "null".  The former is the absence of a value while the latter is a specific literal string.  The isnull() function tests if the given field has no value.

If a lookup command fails to find a match then the OUTPUT fields will be null (empty).

---
If this reply helps you, Karma would be appreciated.
0 Karma

richgalloway
SplunkTrust
SplunkTrust

You have most of it already.  Just on nt_host.  If the value is null then it's not in the lookup.

index=web host!="*TEST*"
| rare limit=10 http_user_agent,c_ip,src,X_Forwarded_For,host
| lookup static_assets ip as c_ip OUTPUT nt_host
| where isnull(nt_host)
| table http_user_agent,c_ip,src_X_Forwarded_For,host,nt_host
---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

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