Splunk Search

can i use "like" in search criteria

alexl1
Path Finder

if one of my fields is host, I want to do

host like "startswith*"

what is the syntax to do that? thanks,

Tags (1)
1 Solution

JSapienza
Contributor

Here are are a couple ways.

  1. host=foo*

  2. ... | where like(host, "foo%")

View solution in original post

pranjal
Engager

whats the best way to compare with a list of items.
I am looking for something like this:
|search where NotificationEventType in ("THE_CHEESEBURGER%", "THE_HAMBURGER%", "ETC%"...)

0 Karma

th1agarajan
Path Finder

@bcherdak : What is the best way to exclude event that start with foo*?

your search | where NOT like(host,"foo%")

This should do the magic.

0 Karma

ddrillic
Ultra Champion

-- bcherdak, you asked - "What is the best way to exclude event that start with foo*?"

I would say - ... NOT host = "foo*"

0 Karma

jtacy
Builder

While it's probably safe to use NOT host="foo*" since the host field should always exist, I'd favor the host!="foo*" syntax; if you have a pattern you're matching on, you probably expect that field to exist in the results. Using the NOT approach will also return events that are missing the field which is probably not what most people want.

0 Karma

JSapienza
Contributor

Here are are a couple ways.

  1. host=foo*

  2. ... | where like(host, "foo%")

alexl1
Path Finder

thanks! ...

0 Karma

pranjal
Engager

whats the best way to compare with a list of items.
I am looking for something like this:
|search where NotificationEventType in ("THE_CHEESEBURGER%", "THE_HAMBURGER%", "ETC%"...)

0 Karma

bcherdak
New Member

What is the best way to exclude event that start with foo*?

0 Karma

jtacy
Builder

If you want to exclude events where a field doesn't start with foo*, use field!="foo*".

If you want to exclude events where the event itself doesn't start with foo*, you can use _raw!="foo*".

0 Karma
Get Updates on the Splunk Community!

Introduction to Splunk Observability Cloud - Building a Resilient Hybrid Cloud

Introduction to Splunk Observability Cloud - Building a Resilient Hybrid Cloud  In today’s fast-paced digital ...

Observability protocols to know about

Observability protocols define the specifications or formats for collecting, encoding, transporting, and ...

Take Your Breath Away with Splunk Risk-Based Alerting (RBA)

WATCH NOW!The Splunk Guide to Risk-Based Alerting is here to empower your SOC like never before. Join Haylee ...