Splunk Search

Help using eval case statement using wildcards

johnward4
Communicator

I'm trying to create a new field for category based off values in my existing 'message' field.

index=network sourcetype=test
| eval category = case (like(message,"*port scan detected*"), "Network_Port_Scan", like(message,"Gateway Anti-Virus Alert*"), like(message,"*Possible TCP Flood*")), "Network_Threat_Activity", like(message,"*packet dropped*" like(message,"*connection dropped*" like(message,"*protocol dropped*"))), "Network_Wire_Activity")

Does anyone know how I accomplish this?

0 Karma
1 Solution

woodcock
Esteemed Legend

Asterisks are wild only for search and base searches. For eval and where, they are string literals so you MUST use something else like, like() or match().

View solution in original post

woodcock
Esteemed Legend

Asterisks are wild only for search and base searches. For eval and where, they are string literals so you MUST use something else like, like() or match().

johnward4
Communicator

@woodcock can I using OR operators inside a given like() statement?

example :

| eval category = case (like(message,"%port scan detected%"), "Network_Port_Scan", like(message,"%Gateway Anti-Virus Alert%" OR "%TCP Flood%"), "Network_Threat_Activity")

0 Karma

woodcock
Esteemed Legend

No but you can like() OR like() and you can use SQL boolean syntax or use match(message, "foo|bar|bat").

0 Karma
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...