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!

Splunk App Dev Community Updates – What’s New and What’s Next

Welcome to your go-to roundup of everything happening in the Splunk App Dev Community! Whether you're building ...

The Latest Cisco Integrations With Splunk Platform!

Join us for an exciting tech talk where we’ll explore the latest integrations in Cisco + Splunk! We’ve ...

Enterprise Security Content Update (ESCU) | New Releases

In April, the Splunk Threat Research Team had 2 releases of new security content via the Enterprise Security ...