Splunk Search

Using Lookups in Splunk with CASE statements

JuhiSaxena
Explorer

I am using CASE statements to evaluate value of msgcode variable below. Can this set of CASE-like statements be replaced with a lookup in Splunk?

eval msgcode=CASE(Error LIKE "%Not a valid path to a statistics probe%","1", Error LIKE "%invalid message size%maximum size expected was%","1",Error LIKE "%eartbeat manager is disconnecting an unresponsive%","1",Error LIKE "%attempted to publish a message larger than the sow store slab size size and the processing of that message has been aborted%","1", Error LIKE "%sow%error%","1",Error LIKE "%transaction log unable to execute journal action%","1",Error LIKE "%client reaper detected a client which has not been reaped %","1",Error LIKE "%HTTP interface to statistics is currently unavailable%","1",Error LIKE "%waiting for %to complete%","1",Error LIKE "%Failed to parse the query string%","1",Error LIKE "%" ,"0") | eval Time=strftime(_time, "%m/%d %H:%M:%S") | table Time,Error,host,sourcetype,count,msgcode | dedup Time,Error,host,sourcetype,count,msgcode | eval trigger=CASE (msgcode==0, "yes", msgcode==1 AND count>=3,"yes",msgcode==1 AND count<3,"no") | where trigger="yes"

0 Karma

koshyk
Super Champion

If using front-end UI Search
I'm not aware of match options within a lookup.

**If using backend conf **
If you are using "conf" files You could do completely avoid eval-CASE to a certain based based on lookup file with normal lookup and/or wildcard lookup (MATCH_TYPE). But this is NOT possible to avoid a value in between the string,

In Summary, i don't think you can avoid CASE statement that easily as per your example strings.

0 Karma

starcher
Influencer
Get Updates on the Splunk Community!

Enter the Dashboard Challenge and Watch the .conf24 Global Broadcast!

The Splunk Community Dashboard Challenge is still happening, and it's not too late to enter for the week of ...

Join Us at the Builder Bar at .conf24 – Empowering Innovation and Collaboration

What is the Builder Bar? The Builder Bar is more than just a place; it's a hub of creativity, collaboration, ...

Combine Multiline Logs into a Single Event with SOCK - a Guide for Advanced Users

This article is the continuation of the “Combine multiline logs into a single event with SOCK - a step-by-step ...