Splunk Search

lookup table to search lookup table?

amask38
Engager

I have been trying to figure out why this doesn't work.

|inputlookup ioc_domain.csv | table query | search NOT [inputlookup ioc_domain.csv | table query]

 

Obviously the above is a useless query but I think the reason it won't work is the same reason my query wont' work which is basically |tstats count where index=dns by PREFIX(query=) PREFIX(srcip=) | rename *= AS * | search NOT [inputlookup ioc_domain.csv | table query]

It's not that exactly but close enough. The main part of the search works fine, if I search without the exclusion everything goes as expected. If I try and use a set of values from a field in a lookup table to act as a filter of events not to include it doesn't work no matter what I try.

I've tried in the subsearch piping to: | rename field AS search | format], I 've tried just | table field], I've tried using return. Nothing seems to work. 

Although it seems to work if the subsearch before any other pipe command, but I'm not interested in that I'm trying to convert some alerts to using tstats and need to be able to scrub against a lookup table. For more info, I'm not using tstats against datasets or datamodels, this is against indexes.

Anyone have any ideas

Labels (2)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

@amask38 I believe the problem is that the field 'query' as returned by the subsearch is handled differently to other fields. If you do 

|inputlookup ioc_domain.csv | table query | format

you will see something like

( ( "A") OR ( "B" ) OR ( "C" ) )

whereas if you do

|inputlookup ioc_domain.csv | table query | rename query as q | format

 you will see 

( ( q="A") OR ( q="B" ) OR ( q="C" ) )

Now if you have a _raw field, then the first form would work because it would search NOT that string in _raw and it would give you no results in your example. As you are trying to use this with tstats, there is no _raw field, so it will not work unless you have the second form, where the field name is part of the eventual search fragment.

View solution in original post

bowesmana
SplunkTrust
SplunkTrust

@amask38 I believe the problem is that the field 'query' as returned by the subsearch is handled differently to other fields. If you do 

|inputlookup ioc_domain.csv | table query | format

you will see something like

( ( "A") OR ( "B" ) OR ( "C" ) )

whereas if you do

|inputlookup ioc_domain.csv | table query | rename query as q | format

 you will see 

( ( q="A") OR ( q="B" ) OR ( q="C" ) )

Now if you have a _raw field, then the first form would work because it would search NOT that string in _raw and it would give you no results in your example. As you are trying to use this with tstats, there is no _raw field, so it will not work unless you have the second form, where the field name is part of the eventual search fragment.

amask38
Engager

Wow, that worked. Odd I have to rename the field before and after the exclusion but it works so I'll roll with it. Thanks!

0 Karma

bowesmana
SplunkTrust
SplunkTrust
0 Karma

PickleRick
Ultra Champion

Yes, there is a mention in the subsearch general docs page but there is not a single word about this formatting on the page describing the format command.

0 Karma

PickleRick
Ultra Champion

That's interesting. Another notice to docs team 😉 The description of format command doesn't mention that behaviour.

0 Karma

PickleRick
Ultra Champion

Use [ | inputlookup ], not [ inputlookup ]

0 Karma
Get Updates on the Splunk Community!

Maximize the Value from Microsoft Defender with Splunk

 Watch NowJoin Splunk and Sens Consulting for this Security Edition Tech TalkWho should attend:  Security ...

This Week's Community Digest - Splunk Community Happenings [6.27.22]

Get the latest news and updates from the Splunk Community here! News From Splunk Answers ✍️ Splunk Answers is ...

Reminder! Splunk Love Promo: $25 Visa Gift Card for Your Honest SOAR Review With ...

We recently launched our first Splunk Love Special, and it's gone phenomenally well, so we're doing it again, ...