Splunk Search

How can I use a variable as parameter for a custom command?

HustenHelmut334
New Member

This is not working: Is there a special syntax to use the content of a variable an not its name?

sourcetype="test"
|stats
|eval minute=tonumber(strftime(_time,"%M"))
|eval foo=250
|eval th=if(minute > 30,"foo=100:200","foo=0:0")
|addinfo
|mycustomcommand monitor=test defaults="foo=150" thresholds=th

This working:

|mycustomcommand monitor=test defaults="foo=150" thresholds="foo=100:200"    

Why is th not evaluated?

0 Karma

woodcock
Esteemed Legend

Try this:

sourcetype="test"
|stats
|eval minute=tonumber(strftime(_time,"%M"))
|eval foo="250"
|eval th=if(minute > 30,"foo=100:200","foo=0:0")
|addinfo
| map search="|mycustomcommand monitor=test defaults=\"foo=$foo$\" thresholds=\"$th$\""
0 Karma

woodcock
Esteemed Legend

Try this @spammenot66 and @HustenHelmut334.

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...