Splunk Search

How to find several terms in all _raw ?

mah
Builder

Hi,

I want to find specific strings in all event in order to classify them into two values, like "if there is "A" or "B" or "C" so put it under "OK" value, if not put it in default value "KO".

I tried first this query :

| eval field=if(searchmatch("A"),"OK,"KO")

But I tried ("A" OR "B") and it does not work. 

I don't know how to add other strings in this command. 

Can you help me ?

Labels (1)
Tags (1)
0 Karma
1 Solution

PickleRick
SplunkTrust
SplunkTrust

If you literarily tried

| eval field=if(searchmatch("A" OR "B"),"ok","ko")

You should have gotten an error because it's not a valid search string and also an OR operator needs two boolean expressions as arguments, not string.

If you want a search string "A" OR "B" OR "C", you have to escape the quotes within the string.

| eval field=if(searchmatch("\"A\" OR \"B\" OR \"C\""),"ok","ko")

 

View solution in original post

0 Karma

PickleRick
SplunkTrust
SplunkTrust

If you literarily tried

| eval field=if(searchmatch("A" OR "B"),"ok","ko")

You should have gotten an error because it's not a valid search string and also an OR operator needs two boolean expressions as arguments, not string.

If you want a search string "A" OR "B" OR "C", you have to escape the quotes within the string.

| eval field=if(searchmatch("\"A\" OR \"B\" OR \"C\""),"ok","ko")

 

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