Splunk Search

Partial Matching

rsathish47
Contributor

Hi all,

How do we check field2 contains field1? Please help.

Field1 Value= CA6

Field2 Value= IA6,CA6,CA8,CA9,CA10,CA7,T7,I6,I7,I10,AP7,AP10

Thanks
Sathish R

Tags (2)
0 Karma
1 Solution

lguinn2
Legend

If Field2 is a multivalued field, this will work

yoursearchhere
| eval n=mvfind(Field2,Field1)
| eval FoundIt = if(isnotnull(n),True,False)

Otherwise, try this

yoursearchhere
| eval FoundIt = if(match(Field2,Field1),True,False)

For either of these solutions to work, Field1 cannot contain any regular expression special characters:

\ ^ $ . | ? * + ( ) [ {

View solution in original post

lguinn2
Legend

If Field2 is a multivalued field, this will work

yoursearchhere
| eval n=mvfind(Field2,Field1)
| eval FoundIt = if(isnotnull(n),True,False)

Otherwise, try this

yoursearchhere
| eval FoundIt = if(match(Field2,Field1),True,False)

For either of these solutions to work, Field1 cannot contain any regular expression special characters:

\ ^ $ . | ? * + ( ) [ {

rsathish47
Contributor

Thanks lguinn.. It worked 🙂

0 Karma
Get Updates on the Splunk Community!

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...