Splunk Search

Why is return command not giving desired result?

AL3Z
Builder

Hi,

I'm trying to exclude list of sites from my search from lookup table its not working as expected,

base search

sub search

NOT

(
[| inputlookup instances.csv
| fields instance_id
| return 1000 instance_id])

 

If we use same below as a sub search in my main search it is not giving any events what could be the reason ? do we need to modify sub search ?

| inputlookup instances.csv | fields instance_id | return 1000 instance_id

 

output:

instance_id search

  (instance_id="xyz") OR (instance_id="abc.com") OR (instance_id="cpl.com") OR (instance_id="ipl.com") OR (instance_id="bcci.com") OR (instance_id="pca.com") OR (instance_id="eca.com") OR (instance_id="aca.com") OR (instance_id="nca.com") OR (instance_id="ica.com") OR (instance_id="bca.com")
Labels (1)
0 Karma

AL3Z
Builder

are you sure that in the main search the field is exactly named "instance_id"?      -----> yes

if not, rename it in the subsearch         --------------->    No

If we use <your_search>  [ | inputlookup instances.csv | fields instance_id ] its not filtering events.

Using [ | inputlookup instances.csv | fields instance_id | return 1000 instance_id]  its filtering all the events. 

in my scenario we are using NOT to excludes these instances from my search.

 

Thanks..

 

 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @AL3Z ,

I understood the you need the NOT condition, but it was only for debugging!

For my knowledge it should run without return, but with return have you the required filtering or not?

Ciao.

Giuseppe

0 Karma

AL3Z
Builder

yup,with return we do have  required filtering.

 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @AL3Z,

so what's the issue with the above search and subsearch?

ciao.

Giuseppe

0 Karma

AL3Z
Builder

In the sub search we need to use the return 1000 or not ?

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @AL3Z,

I usually don't use it, but if, in you case, the search runs only with return, use it!

Ciao.

Giuseppe

0 Karma

AL3Z
Builder

yes, no its working if I put  | return 1000 instance_id

thanks...

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @AL3Z,

I usually not use return in subsearches without issue, with the only attention to use the field name in main and sub searches!

what do you mean with " no its working if I put  | return 1000 instance_id"?

does it filter results or not?

what's the difference using also returns?

What does it happen if you don't use NOT, have you results?

Usually the problem is the opposite: it runs without negation and runs with NOT.

Ciao.

Giuseppe

0 Karma

AL3Z
Builder

It is not working...

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @AL3Z ,

are you sure that in the main search the field is exactly named "instance_id"?

if not, rename it in the subsearch

ciao.

Giuseppe

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @AL3Z,

did you already tried an easier solution?

<your_search> NOT [ | inputlookup instances.csv | fields instance_id ]

Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

What the End of Support for Splunk Add-on Builder Means for You

Hello Splunk Community! We want to share an important update regarding the future of the Splunk Add-on Builder ...

Solve, Learn, Repeat: New Puzzle Channel Now Live

Welcome to the Splunk Puzzle PlaygroundIf you are anything like me, you love to solve problems, and what ...

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...