Splunk Search

Can I use a macro within a macro?

Dimitri_McKay
Splunk Employee
Splunk Employee

Wondering if it's possible to embed a macro into another macro.

Tags (2)
0 Karma

edschembor
Path Finder

See the Splunk documentation for this: http://docs.splunk.com/Splexicon:Searchmacro

Directly from the docs: "You can also nest search macros within each other."

somesoni2
Revered Legend

Yes it is possible.

Here is one example.
Definition

macros.conf

[getCountStatus(1)]
args = count
definition = eval CountStatus=if($count$>100,"Heavy","Light")
iseval = 0

[getRowColorWithCountStatus(1)]
args = count
definition = `getCountStatus($count$)` | eval RowColor=if(CountStatus="Heavy","Read","Green")
iseval = 0

Usage:

index=_internal earliest=-15m@m  | stats count by sourcetype |`getRowColorWithCountStatus(count)`
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

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

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...