Splunk Search

How to search a field for text from another field?

techusky
Explorer

It seems like this should be something pretty simple to do, so I hope I'm not just overlooking something.

Let's say I have Field_A that contains a full email address and Field_B that contains only a domain. What I'm trying to do is search Field_A and see if the text in Field_B is not found. My first thought was something along the lines of:

where not like(Field_A, %Field_B%)

But those percent wildcards can only be used for a search string... whereas I don't have that.

I hope that makes sense. Thanks!

1 Solution

somesoni2
Revered Legend

You should be able to user WHERE OR search to do this (even with field value). Try something like this

your base search | where NOT LIKE(Field_A,"%".Field_B."%") 

OR 

Your base search | where NOT match(Field_A,".*".Field_B.".*") 

OR 

your base search | search Field_A!=".*".Field_B.".*"

View solution in original post

somesoni2
Revered Legend

You should be able to user WHERE OR search to do this (even with field value). Try something like this

your base search | where NOT LIKE(Field_A,"%".Field_B."%") 

OR 

Your base search | where NOT match(Field_A,".*".Field_B.".*") 

OR 

your base search | search Field_A!=".*".Field_B.".*"

techusky
Explorer

Thanks, I figured I was just goofing something simple up.

I wound up just doing: where NOT match(Field_A, Field_B)

0 Karma

pradeepkumarg
Influencer

Extract domain from Field_A into a new field Field_Domain and then compare it with Field_B. Does that work for you?

0 Karma

techusky
Explorer

Unfortunately no. Let me explain a bit more with a better example:

Field_A = m-1hq98whvnq8p6d9ibr2qagqs1ukaz1usy9ozufub8rkr0ur0ji82mw8t0e833@bounce.linkedin.com
Field_B = linkedin.com

If I extracted the domain from Field_A, it would be "bounce.linkedin.com"... What I want to do is basically search Field_A for Field_B and see if it occurs anywhere in the string. If you're familiar with PHP or other similar languages, what I'm looking for is the functionality of the stristr function.

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...