Splunk Search

How to remove sourcetype from this search?

echojacques
Builder

Hi,

This is one of the canned correlation searches included in Splunk Enterprise Security. How can I exclude events from a specific sourcetype from this search? My attempt to do this (which didn't work) is also below.

The original search:

| `src_dest_tracker("allowed")` | lookup local=true sans_blocklist_lookup src OUTPUTNEW src_ip as src_sans_ip,src_is_sans | lookup local=true sans_blocklist_lookup dest OUTPUTNEW dest_ip as dest_sans_ip,dest_is_sans | search dest_is_sans=true OR src_is_sans=true | eval sans_ip=if(dest_is_sans=="true",dest_sans_ip,sans_ip) | eval sans_ip=if(src_is_sans=="true",src_sans_ip,sans_ip) | fields + sourcetype,src,dest,sans_ip

My attempt to remove results from a sourcetype:

sourcetype!="IPS" | `src_dest_tracker("allowed")` | lookup local=true sans_blocklist_lookup src OUTPUTNEW src_ip as src_sans_ip,src_is_sans | lookup local=true sans_blocklist_lookup dest OUTPUTNEW dest_ip as dest_sans_ip,dest_is_sans | search dest_is_sans=true OR src_is_sans=true | eval sans_ip=if(dest_is_sans=="true",dest_sans_ip,sans_ip) | eval sans_ip=if(src_is_sans=="true",src_sans_ip,sans_ip) | fields + sourcetype,src,dest,sans_ip

My attempt produced the error: "Error in 'tstats' command: This command must be the first command of a search". I tried placing the "sourcetype!="IPS" elsewhere in the search string but just got more errors. Any help is appreciated. Thanks!

Tags (2)
0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

Try this (if not already tried)

| `src_dest_tracker("allowed")` | search NOT sourcetype="IPS" | lookup local=true sans_blocklist_lookup src OUTPUTNEW src_ip as src_sans_ip,src_is_sans | lookup local=true sans_blocklist_lookup dest OUTPUTNEW dest_ip as dest_sans_ip,dest_is_sans | search dest_is_sans=true OR src_is_sans=true | eval sans_ip=if(dest_is_sans=="true",dest_sans_ip,sans_ip) | eval sans_ip=if(src_is_sans=="true",src_sans_ip,sans_ip) | fields + sourcetype,src,dest,sans_ip

View solution in original post

lguinn2
Legend

I don't know exactly what is in the src_dest_tracker macro, so there might be a more efficient way to do what you want, but this will work

| `src_dest_tracker("allowed")` 
| where sourcetype!="IPS" 
| lookup local=true sans_blocklist_lookup src OUTPUTNEW src_ip as src_sans_ip,src_is_sans | lookup local=true sans_blocklist_lookup dest OUTPUTNEW dest_ip as dest_sans_ip,dest_is_sans | search dest_is_sans=true OR src_is_sans=true | eval sans_ip=if(dest_is_sans=="true",dest_sans_ip,sans_ip) | eval sans_ip=if(src_is_sans=="true",src_sans_ip,sans_ip) | fields + sourcetype,src,dest,sans_ip

The macro contains the initial search, so your condition must follow that. Note I put in in a where command, as the second command in the pipeline. Everything else remains the same.

echojacques
Builder

This also worked, but I could only select one answer as the "answer". But thank you!

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Try this (if not already tried)

| `src_dest_tracker("allowed")` | search NOT sourcetype="IPS" | lookup local=true sans_blocklist_lookup src OUTPUTNEW src_ip as src_sans_ip,src_is_sans | lookup local=true sans_blocklist_lookup dest OUTPUTNEW dest_ip as dest_sans_ip,dest_is_sans | search dest_is_sans=true OR src_is_sans=true | eval sans_ip=if(dest_is_sans=="true",dest_sans_ip,sans_ip) | eval sans_ip=if(src_is_sans=="true",src_sans_ip,sans_ip) | fields + sourcetype,src,dest,sans_ip

echojacques
Builder

This worked perfectly, thank you!

0 Karma
Get Updates on the Splunk Community!

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...