Splunk Search

How to use macros in tstats and calling different macros based on the value of the parameter

splunkrocks2014
Communicator

Hi. I wanted to use a macro to call a different macro based on the parameter and the definition of the sub-macro is from the "tstats" command. For example,

[parentMacro(1)]
args=source
definition=CASE($source$="xyz", `childMacro_xyz`, $source$="abc", `childMacro_abc`)

[childMacro_xyz]
definition= tstats count WHERE index=blah where source="xyz" 

[childMacro_abc]
definition= tstats count WHERE index=blah where source="abc"

I got "Search Factory: Unknown search command 'case'" while using the following

| makeresults 
| eval source="xyz"
|`parentMacro(source)`

Any clues? Thanks.

Tags (1)
0 Karma

gjanders
SplunkTrust
SplunkTrust
 | search`parentMacro(source)`

?
Or include the search command in the macro, although that might only fix the first issue I can see there...

0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...