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!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...