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!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...