Splunk Search

Splunk search - How to search the fields1 values contains in field2

kartm2020
Communicator

Hi All, Hope you guys are doing fine.
I do have few doubts with relates to field comparison. Please find the below sample data.

Field1Field2
TRAP_BGPBGP BACKWARD TRANSITION
TRAP_BFDCISCO BFD SESS DOWN
Interface GigabitEthernet0/0BGP BACKWARD TRANSITION
TRAP_LINKLINK UP/DOWN TRAPS RECEIVED IN THE LAST 5 MINUTES EXCEEDS THRESHOLD

 

I need to check the value of field1 is containing in field2(partial match). From the above example, TRAP_BGP and BGP BACKWARD TRANSITION. in this both words BGP is common. if it is common then the result should "YES".

This is sample data, we do have multiple data with this format(This data is dynamic not static).

Can someone please help with the SPL query. I have tried match, LIKE command but it doesn't seems to be working.

Labels (3)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| makeresults
| eval _raw="TRAP_BGP,BGP BACKWARD TRANSITION
TRAP_BFD,CISCO BFD SESS DOWN
Interface GigabitEthernet0/0,BGP BACKWARD TRANSITION
TRAP_LINK,LINK UP/DOWN TRAPS RECEIVED IN THE LAST 5 MINUTES EXCEEDS THRESHOLD"
| multikv noheader=t
| rename Column_* as field*
| table field*



| eval field2=replace(field2," ", "|")
| eval match=if(match(field1,field2),"yes",null())

View solution in original post

0 Karma

kartm2020
Communicator

Hi ITWhisperer,

Thanks a lot for this idea. It worked. but it is not working for some fields.
Ex: Field1=Interface Ethernet1/45 Field2=LINK|UP/DOWN|TRAPS|RECEIVED|IN|THE|LAST|5|MINUTES|EXCEEDS|THRESHOLD
I am getting yes for this scenario. but Interface and ethernet is not present field2. Can you please provide an explanation. Thank you

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

"5" exists in both fields

0 Karma

kartm2020
Communicator

Is there any way to find the exact partial match of word.. Like adding condition ?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

I am not sure what you mean by "exact partial" - essentially field 2 needs to have the options delimited by pipe symbols - you could try replacing only some of the spaces if you can define some rules, for example, spaces before and/or after numbers should not be replaced.

0 Karma

kartm2020
Communicator

Hi,

Thanks a lot for your prompt reply and giving me this idea. I will accept your answer.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| makeresults
| eval _raw="TRAP_BGP,BGP BACKWARD TRANSITION
TRAP_BFD,CISCO BFD SESS DOWN
Interface GigabitEthernet0/0,BGP BACKWARD TRANSITION
TRAP_LINK,LINK UP/DOWN TRAPS RECEIVED IN THE LAST 5 MINUTES EXCEEDS THRESHOLD"
| multikv noheader=t
| rename Column_* as field*
| table field*



| eval field2=replace(field2," ", "|")
| eval match=if(match(field1,field2),"yes",null())
0 Karma
Get Updates on the Splunk Community!

Observability | How to Think About Instrumentation Overhead (White Paper)

Novice observability practitioners are often overly obsessed with performance. They might approach ...

Cloud Platform | Get Resiliency in the Cloud Event (Register Now!)

IDC Report: Enterprises Gain Higher Efficiency and Resiliency With Migration to Cloud  Today many enterprises ...

The Great Resilience Quest: 10th Leaderboard Update

The tenth leaderboard update (11.23-12.05) for The Great Resilience Quest is out >> As our brave ...