<?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 prevent | stats count in a macro from triggering a remote search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115185#M30471</link>
    <description>&lt;P&gt;Using | stats count is often useful to do a quick test&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | some search where you do not need event data
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I wanted to use that mechanism/pattern in a macro that does modifications to a lookup. The macro is called/used by a workflow action&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[test]
definition = | stats count | do stuff with a lookup
iseval = 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Calling the macro triggers a remote search and takes much longer than doing the same directly in the search field in the default search view. &lt;BR /&gt;
Is there a way around this? Is this the wrong aproach? &lt;BR /&gt;
I could embed the search directly in the work flow action but I would like to pass on the name of the lookup that should get modified.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Update 09.09.2014&lt;/P&gt;

&lt;P&gt;Thanks for you suggestions MuS &amp;amp; martin_mueller, they did not work for me at least not the way i tried them:&lt;/P&gt;

&lt;P&gt;If I add &lt;CODE&gt;splunk_server=local&lt;/CODE&gt; to the beginning of the macro a remote search is still triggered:&lt;BR /&gt;
&lt;IMG src="http://answers.splunk.com//storage/remoteSearch_1.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;If I try with inputlookup as the first command of the macro I get an error:&lt;BR /&gt;
&lt;IMG src="http://answers.splunk.com//storage/inputlookup.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;If I just enter a &lt;CODE&gt;| stats count&lt;/CODE&gt; in the search field the job inspector shows the following:&lt;BR /&gt;
&lt;IMG src="http://answers.splunk.com//storage/stats_count.png" alt="alt text" /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 08 Sep 2014 12:29:41 GMT</pubDate>
    <dc:creator>chris</dc:creator>
    <dc:date>2014-09-08T12:29:41Z</dc:date>
    <item>
      <title>How to prevent | stats count in a macro from triggering a remote search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115185#M30471</link>
      <description>&lt;P&gt;Using | stats count is often useful to do a quick test&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | some search where you do not need event data
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I wanted to use that mechanism/pattern in a macro that does modifications to a lookup. The macro is called/used by a workflow action&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[test]
definition = | stats count | do stuff with a lookup
iseval = 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Calling the macro triggers a remote search and takes much longer than doing the same directly in the search field in the default search view. &lt;BR /&gt;
Is there a way around this? Is this the wrong aproach? &lt;BR /&gt;
I could embed the search directly in the work flow action but I would like to pass on the name of the lookup that should get modified.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Update 09.09.2014&lt;/P&gt;

&lt;P&gt;Thanks for you suggestions MuS &amp;amp; martin_mueller, they did not work for me at least not the way i tried them:&lt;/P&gt;

&lt;P&gt;If I add &lt;CODE&gt;splunk_server=local&lt;/CODE&gt; to the beginning of the macro a remote search is still triggered:&lt;BR /&gt;
&lt;IMG src="http://answers.splunk.com//storage/remoteSearch_1.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;If I try with inputlookup as the first command of the macro I get an error:&lt;BR /&gt;
&lt;IMG src="http://answers.splunk.com//storage/inputlookup.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;If I just enter a &lt;CODE&gt;| stats count&lt;/CODE&gt; in the search field the job inspector shows the following:&lt;BR /&gt;
&lt;IMG src="http://answers.splunk.com//storage/stats_count.png" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Sep 2014 12:29:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115185#M30471</guid>
      <dc:creator>chris</dc:creator>
      <dc:date>2014-09-08T12:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent | stats count in a macro from triggering a remote search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115186#M30472</link>
      <description>&lt;P&gt;How about :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;splunk_server=local | stats count | foo boo
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Sep 2014 12:34:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115186#M30472</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-09-08T12:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent | stats count in a macro from triggering a remote search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115187#M30473</link>
      <description>&lt;P&gt;Depending on what stuff you want to do with a lookup you may use &lt;CODE&gt;inputlookup&lt;/CODE&gt; instead.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Sep 2014 13:17:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115187#M30473</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-09-08T13:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent | stats count in a macro from triggering a remote search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115188#M30474</link>
      <description>&lt;P&gt;can you try either &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup append=t
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| lookup local=true
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Sep 2014 13:03:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115188#M30474</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-09-09T13:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent | stats count in a macro from triggering a remote search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115189#M30475</link>
      <description>&lt;P&gt;Thanks for the suggestion, the problem remains the same though. I am fine running this manually from search form but as soon as the command is packed into a macro a search is triggered. I think macros should either do a proper search or not be the first part of a search ... -&amp;gt; If I take the first pipe out of the macro I'm fine: | &lt;CODE&gt;macro&lt;/CODE&gt; -&amp;gt; and the macro contains "inputlookup append=t somename" or "stats count"&lt;/P&gt;</description>
      <pubDate>Wed, 10 Sep 2014 14:11:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115189#M30475</guid>
      <dc:creator>chris</dc:creator>
      <dc:date>2014-09-10T14:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent | stats count in a macro from triggering a remote search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115190#M30476</link>
      <description>&lt;P&gt;Ah. Yeah, that's normal.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| `some macro`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With the macro not containing the pipe at the beginning.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Sep 2014 15:02:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115190#M30476</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-09-10T15:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent | stats count in a macro from triggering a remote search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115191#M30477</link>
      <description>&lt;P&gt;Do you know why?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Sep 2014 19:42:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115191#M30477</guid>
      <dc:creator>chris</dc:creator>
      <dc:date>2014-09-11T19:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent | stats count in a macro from triggering a remote search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115192#M30478</link>
      <description>&lt;P&gt;Technically not "why", but I can explain further. Say you have two macros like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[pipe]
definition = | stats count
iseval = 0
[nopipe]
definition = stats count
iseval = 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When you run this search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| `nopipe`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and look at the search inspector you see these:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search:           | `nopipe`
normalizedSearch: prestats count
remoteSearch:     prestats count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In other words, Splunk tells its search peers "do nothing, and tell me how many events you found" - yielding a zero very quickly. The explicit pipe at the beginning suppresses the implicit &lt;CODE&gt;search&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Sep 2014 20:06:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115192#M30478</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-09-11T20:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent | stats count in a macro from triggering a remote search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115193#M30479</link>
      <description>&lt;P&gt;Now to compare, you run this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;`pipe`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;expecting the search to do the same after macro replacement. However, that's not the case when looking at the search inspector:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search: search `pipe`
normalizedSearch: litsearch | addinfo type=count label=prereport_events | fields keepcolorder=t "prestats_reserved_*" "psrsvd_*" | prestats count
remoteSearch: litsearch | addinfo type=count label=prereport_events | fields keepcolorder=t "prestats_reserved_*" "psrsvd_*" | prestats count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here, Splunk's telling its search peers "Run a search with no filters and count"... EEEEEEP!&lt;/P&gt;</description>
      <pubDate>Thu, 11 Sep 2014 20:08:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115193#M30479</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-09-11T20:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent | stats count in a macro from triggering a remote search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115194#M30480</link>
      <description>&lt;P&gt;Without the explicit pipe at the beginning the implicit &lt;CODE&gt;search&lt;/CODE&gt; command gets added &lt;STRONG&gt;before macro replacement&lt;/STRONG&gt;, effectively making the search &lt;CODE&gt;* | stats count&lt;/CODE&gt;. Hence you're counting ALL the events, taking a long time.&lt;/P&gt;

&lt;P&gt;That's what's happening, but don't ask me why...&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://answers.splunk.com//storage/all-the-things-meme-generator-inventory-count-all-the-things-cb7ac6.jpg" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Sep 2014 20:09:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115194#M30480</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-09-11T20:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent | stats count in a macro from triggering a remote search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115195#M30481</link>
      <description>&lt;P&gt;&lt;CODE&gt;| localop | stats count&lt;/CODE&gt; -&amp;gt; remoteSearch = None&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2015 19:29:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-prevent-stats-count-in-a-macro-from-triggering-a-remote/m-p/115195#M30481</guid>
      <dc:creator>mikebd</dc:creator>
      <dc:date>2015-10-11T19:29:33Z</dc:date>
    </item>
  </channel>
</rss>

