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

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

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!

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