<?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: How to pass an argument to a macro and execute this macro repeatedly using &amp;quot;by source&amp;quot;? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-an-argument-to-a-macro-and-execute-this-macro/m-p/222942#M43694</link>
    <description>&lt;P&gt;try like &lt;BR /&gt;
(c) &lt;CODE&gt;index=… sourcetype=… | perSITEinfo_with_args(specific-file-name-source-within…zip-file) by source&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;or&lt;BR /&gt;
definition: &lt;CODE&gt;search   index=… sourcetype=… $in_source$ | series of search | stats perc50(X) dc(Y) values(Z) by source&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;after run with &lt;CODE&gt;source=specific-file-name-source&lt;/CODE&gt;  args  like this  :&lt;BR /&gt;
 perSITEinfo_with_args(source=specific-file-name-within…zip-file) &lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 08:55:06 GMT</pubDate>
    <dc:creator>fdi01</dc:creator>
    <dc:date>2020-09-29T08:55:06Z</dc:date>
    <item>
      <title>How to pass an argument to a macro and execute this macro repeatedly using "by source"?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-an-argument-to-a-macro-and-execute-this-macro/m-p/222941#M43693</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I would like to execute macro_with_args repeatedly using by source. How can I pass the arg_value to the macro?&lt;/P&gt;

&lt;P&gt;Context:  syslog-like events from over thousands sites for a given time range are saved in each site-source-file. As a whole, …zip file is added to Splunk.   For one site-source-file, I made search series and got a desired result (a), then defined the macro_with_args by extracting a core search series from (a) as (b). The defined macro was tested alone and got the same result as (a) did.&lt;/P&gt;

&lt;P&gt;(a) &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=… sourcetype=… source=specific-file-name-within…zip-file | series of search  |  stats  perc50(X) dc(Y)  values(Z)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(b)&lt;BR /&gt;&lt;BR /&gt;
macro name: perSITEinfo_with_args(1)&lt;BR /&gt;
definition: &lt;CODE&gt;search source=$in_source$ | series of search | stats  perc50(X)  dc(Y)  values(Z)&lt;/CODE&gt;&lt;BR /&gt;
args:  in_source&lt;/P&gt;

&lt;P&gt;As a new search, I expected the following search (c) work, but got no results:&lt;BR /&gt;&lt;BR /&gt;
(c) &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=…  sourcetype=…   | `perSITEinfo_with_args(source)` by source
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Q1: How can I pass the arg_value to the macro?&lt;BR /&gt;
Q2: Does this approach (macro call repeatedly) work?&lt;BR /&gt;
       If not, what is another approach?  Sub search?&lt;BR /&gt;
       It is appreciated if a “transformation” way from macro approach to another approach were explained.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 08:56:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-an-argument-to-a-macro-and-execute-this-macro/m-p/222941#M43693</guid>
      <dc:creator>tac24</dc:creator>
      <dc:date>2020-09-29T08:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass an argument to a macro and execute this macro repeatedly using "by source"?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-an-argument-to-a-macro-and-execute-this-macro/m-p/222942#M43694</link>
      <description>&lt;P&gt;try like &lt;BR /&gt;
(c) &lt;CODE&gt;index=… sourcetype=… | perSITEinfo_with_args(specific-file-name-source-within…zip-file) by source&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;or&lt;BR /&gt;
definition: &lt;CODE&gt;search   index=… sourcetype=… $in_source$ | series of search | stats perc50(X) dc(Y) values(Z) by source&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;after run with &lt;CODE&gt;source=specific-file-name-source&lt;/CODE&gt;  args  like this  :&lt;BR /&gt;
 perSITEinfo_with_args(source=specific-file-name-within…zip-file) &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 08:55:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-an-argument-to-a-macro-and-execute-this-macro/m-p/222942#M43694</guid>
      <dc:creator>fdi01</dc:creator>
      <dc:date>2020-09-29T08:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass an argument to a macro and execute this macro repeatedly using "by source"?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-an-argument-to-a-macro-and-execute-this-macro/m-p/222943#M43695</link>
      <description>&lt;P&gt;Hi, fdi01, thanks for your answer.&lt;BR /&gt;
 I tried your two solutions, unfortunately, they did not work.&lt;/P&gt;</description>
      <pubDate>Sat, 27 Feb 2016 01:00:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-an-argument-to-a-macro-and-execute-this-macro/m-p/222943#M43695</guid>
      <dc:creator>tac24</dc:creator>
      <dc:date>2016-02-27T01:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass an argument to a macro and execute this macro repeatedly using "by source"?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-an-argument-to-a-macro-and-execute-this-macro/m-p/222944#M43696</link>
      <description>&lt;P&gt;If the "series of search" is the same for all different sources, then you don't need a macro, although you could build one for the "source=" list below. Try this -   &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index=…  sourcetype=…  (source=filename1withinzip OR source=filename1withinzip OR source=filename1withinzip ...) | series of search | stats perc50(X) dc(Y) values(Z) by source
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Jan 2017 20:30:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-an-argument-to-a-macro-and-execute-this-macro/m-p/222944#M43696</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-01-05T20:30:31Z</dc:date>
    </item>
  </channel>
</rss>

