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

PickleRick
SplunkTrust
SplunkTrust

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
SplunkTrust
SplunkTrust

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

0 Karma

PickleRick
SplunkTrust
SplunkTrust

Use [ | inputlookup ], not [ inputlookup ]

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

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 ...