<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to use macros in tstats and calling different macros based on the value of the parameter in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-macros-in-tstats-and-calling-different-macros-based/m-p/384047#M168885</link>
    <description>&lt;P&gt;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,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[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"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I got "Search Factory: Unknown search command 'case'" while using the following &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval source="xyz"
|`parentMacro(source)`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any clues?  Thanks.&lt;/P&gt;</description>
    <pubDate>Thu, 14 Jun 2018 15:29:34 GMT</pubDate>
    <dc:creator>splunkrocks2014</dc:creator>
    <dc:date>2018-06-14T15:29:34Z</dc:date>
    <item>
      <title>How to use macros in tstats and calling different macros based on the value of the parameter</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-macros-in-tstats-and-calling-different-macros-based/m-p/384047#M168885</link>
      <description>&lt;P&gt;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,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[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"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I got "Search Factory: Unknown search command 'case'" while using the following &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval source="xyz"
|`parentMacro(source)`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any clues?  Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jun 2018 15:29:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-macros-in-tstats-and-calling-different-macros-based/m-p/384047#M168885</guid>
      <dc:creator>splunkrocks2014</dc:creator>
      <dc:date>2018-06-14T15:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to use macros in tstats and calling different macros based on the value of the parameter</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-macros-in-tstats-and-calling-different-macros-based/m-p/384048#M168886</link>
      <description>&lt;PRE&gt;&lt;CODE&gt; | search`parentMacro(source)`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;?&lt;BR /&gt;
Or include the search command in the macro, although that might only fix the first issue I can see there...&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jun 2018 08:53:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-macros-in-tstats-and-calling-different-macros-based/m-p/384048#M168886</guid>
      <dc:creator>gjanders</dc:creator>
      <dc:date>2018-06-15T08:53:26Z</dc:date>
    </item>
  </channel>
</rss>

