<?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 Re: macro question - how to use the macro search results to another search? in Knowledge Management</title>
    <link>https://community.splunk.com/t5/Knowledge-Management/macro-question-how-to-use-the-macro-search-results-to-another/m-p/134070#M1363</link>
    <description>&lt;P&gt;I have tried it and it works. Thank its a nice start for me  to make use of macros.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Nov 2013 08:50:09 GMT</pubDate>
    <dc:creator>crt89</dc:creator>
    <dc:date>2013-11-08T08:50:09Z</dc:date>
    <item>
      <title>macro question - how to use the macro search results to another search?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/macro-question-how-to-use-the-macro-search-results-to-another/m-p/134068#M1361</link>
      <description>&lt;P&gt;Good day fellow Splunkers,&lt;/P&gt;

&lt;P&gt;I'm new to this macro in Splunk and I want to ask if this could be possible.&lt;/P&gt;

&lt;P&gt;I have 3 monitored folders, I want to start my search to just get the latest source of this 3 folders. So I was thinking can I do a macro search to first filter my sources. 1 for each directory. So I will only have 3 sources to search for my search string.&lt;/P&gt;

&lt;P&gt;The problem is I dont know how to configure the macro to pass the results of the macro search to a  variable that I will be using for my search.&lt;/P&gt;

&lt;P&gt;my sample macro would be:&lt;/P&gt;

&lt;P&gt;host=host1 | stats latest(source) as host1_source_latest&lt;BR /&gt;
(same for the other 2 directory)&lt;/P&gt;

&lt;P&gt;then my search would be source=[the results of the macro] | [my search string]&lt;/P&gt;

&lt;P&gt;This is what I'm planning to do, if there would be other approach it would be much appreciated.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:14:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/macro-question-how-to-use-the-macro-search-results-to-another/m-p/134068#M1361</guid>
      <dc:creator>crt89</dc:creator>
      <dc:date>2020-09-28T15:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: macro question - how to use the macro search results to another search?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/macro-question-how-to-use-the-macro-search-results-to-another/m-p/134069#M1362</link>
      <description>&lt;P&gt;You can use macros in subsearches as you normally would in non-sub-searches. For example, if you have this search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;my search string [search host=host1 | head 1 | fields source]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;where the subsearch will be evaluated to &lt;CODE&gt;source=foo&lt;/CODE&gt;, you can replace the inner contents of the subsearch with a call to a macro. It could then look something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;my search string [`macro`]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Nov 2013 08:18:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/macro-question-how-to-use-the-macro-search-results-to-another/m-p/134069#M1362</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2013-11-08T08:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: macro question - how to use the macro search results to another search?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/macro-question-how-to-use-the-macro-search-results-to-another/m-p/134070#M1363</link>
      <description>&lt;P&gt;I have tried it and it works. Thank its a nice start for me  to make use of macros.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2013 08:50:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/macro-question-how-to-use-the-macro-search-results-to-another/m-p/134070#M1363</guid>
      <dc:creator>crt89</dc:creator>
      <dc:date>2013-11-08T08:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: macro question - how to use the macro search results to another search?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/macro-question-how-to-use-the-macro-search-results-to-another/m-p/134071#M1364</link>
      <description>&lt;P&gt;Note, I have modified the subsearch - should be a much faster way to grab the latest source.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2013 09:01:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/macro-question-how-to-use-the-macro-search-results-to-another/m-p/134071#M1364</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2013-11-08T09:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: macro question - how to use the macro search results to another search?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/macro-question-how-to-use-the-macro-search-results-to-another/m-p/134072#M1365</link>
      <description>&lt;P&gt;edit: forgot to change query strings. solved now. Thanks again&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2013 09:53:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/macro-question-how-to-use-the-macro-search-results-to-another/m-p/134072#M1365</guid>
      <dc:creator>crt89</dc:creator>
      <dc:date>2013-11-08T09:53:36Z</dc:date>
    </item>
  </channel>
</rss>

