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!

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