Other Usage

How to avoid repeating the formula?

hedayaty
Engager

On various occasions I find myself writing formulas like (simplified version):

eval cat=case(like(CC, "TenantA%"), "ABC", like(CC, "TenantB%"), "BBC", true(), "Enterprise") 

Or mapping the hosts to regions

eval site=case(like(host, "%-au%"), "AWS US", like(host, "%-ac%"), "AWS CA", like(host, "%-ae%"), "AWS EU", true(), "UnKnown") 

 Sometime I use the same mappings across many reports dashboards.

Copy/paste does not cut it. Also sometimes they need to get updated. Any suggestion?

Labels (1)
0 Karma
1 Solution

scelikok
SplunkTrust
SplunkTrust

Hi @hedayaty,

Search macros will help you;

https://docs.splunk.com/Documentation/Splunk/8.2.3/Knowledge/Searchmacroexamples

 

If this reply helps you an upvote and "Accept as Solution" is appreciated.

View solution in original post

acharlieh
Influencer

I'd want to try it to be certain, but it sounds like it could be a job for a lookup... with WILDCARD match type defined for some columns:

https://community.splunk.com/t5/Splunk-Search/Can-we-use-wildcard-characters-in-a-lookup-table/m-p/9...


0 Karma

scelikok
SplunkTrust
SplunkTrust

Hi @hedayaty,

Search macros will help you;

https://docs.splunk.com/Documentation/Splunk/8.2.3/Knowledge/Searchmacroexamples

 

If this reply helps you an upvote and "Accept as Solution" is appreciated.

hedayaty
Engager

Did not know about the search macros.

They are very clunky but they do the job!

0 Karma
Get Updates on the Splunk Community!

.conf25 Registration is OPEN!

Ready. Set. Splunk! Your favorite Splunk user event is back and better than ever. Get ready for more technical ...

Detecting Cross-Channel Fraud with Splunk

This article is the final installment in our three-part series exploring fraud detection techniques using ...

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...