Splunk Search

How to use OR or AND in searchmatch(X) function?

dniraula
New Member

I am trying to use following query to generate some report put seems OR and AND is not working in searchmatch.

index=xxx sourcetype=xxxx | timechart count(eval(searchmatch("Login successful OR logged in"))) as Success,count(eval(searchmatch("Authentication failure OR Failed User"))) as Failed by sourcetype

It is working perfectly if I didn't use OR. Is there any alternative query to get same result as above query?

Tags (1)
0 Karma

Ayn
Legend

searchmatch(str) is really just an alias for match(_raw, str) and they're both regex based. So what you need is to use the pipe character which denotes an OR in regex:

... searchmatch("Authentication failure|Failed User")

wrangler2x
Motivator

Actually, what I am finding on the 6.x releases is that using a pipe in searchmatch as OR does not work -- it throws an error. However, if you use the match(_raw,regex) instead, the regex can have a pipe in it there.

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...