Splunk Search

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


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,

definition=CASE($source$="xyz", `childMacro_xyz`, $source$="abc", `childMacro_abc`)

definition= tstats count WHERE index=blah where source="xyz" 

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"

Any clues? Thanks.

Tags (1)
0 Karma

 | 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!

Splunk Forwarders and Forced Time Based Load Balancing

Splunk customers use universal forwarders to collect and send data to Splunk. A universal forwarder can send ...

NEW! Log Views in Splunk Observability Dashboards Gives Context From a Single Page

Today, Splunk Observability releases log views, a new feature for users to add their logs data from Splunk Log ...

Last Chance to Submit Your Paper For BSides Splunk - Deadline is August 12th!

Hello everyone! Don't wait to submit - The deadline is August 12th! We have truly missed the community so ...