<?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 multiple values from a search as parameters to a macro so the macro will be run for each value? in Knowledge Management</title>
    <link>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286211#M2512</link>
    <description>&lt;P&gt;I want to get my list from search if possible. It will be 8 column names. If not I can maybe use CSV file and use inputlookup command&lt;/P&gt;

&lt;P&gt;Then I want to add one column name at the time run a macro then add another and run a macro. At the end result will be comined. &lt;/P&gt;

&lt;P&gt;example data:&lt;BR /&gt;
Name&lt;BR /&gt;
ID&lt;BR /&gt;
ect&lt;/P&gt;

&lt;P&gt;hope this help&lt;/P&gt;</description>
    <pubDate>Thu, 22 Oct 2015 15:28:17 GMT</pubDate>
    <dc:creator>akawacz</dc:creator>
    <dc:date>2015-10-22T15:28:17Z</dc:date>
    <item>
      <title>How to pass multiple values from a search as parameters to a macro so the macro will be run for each value?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286207#M2508</link>
      <description>&lt;P&gt;Hi &lt;/P&gt;

&lt;P&gt;I have created a macro with a parameter. Then I have a list/search with 8 values.&lt;/P&gt;

&lt;P&gt;How is it possible to pass those values into macro as parameters so that macro will be run 8 times and give appended results?&lt;/P&gt;

&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2015 14:23:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286207#M2508</guid>
      <dc:creator>akawacz</dc:creator>
      <dc:date>2015-10-21T14:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass multiple values from a search as parameters to a macro so the macro will be run for each value?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286208#M2509</link>
      <description>&lt;P&gt;First of all, you can call another macro from within a macro.  I assume you are asking how to make a macro that can take a variable number of parameters.  Directly, you cannot, but you can pass in the value for a field which has encoded inside like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | `mymacro("value1;value2;value3;value4;value5;value6;value7;value8")`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then inside the macro, use &lt;CODE&gt;makemv delim=";"&lt;/CODE&gt; to break apart the field into a &lt;CODE&gt;multi-valued&lt;/CODE&gt; field and then use &lt;CODE&gt;mvexpand&lt;/CODE&gt; to create separate events on which to operate, perhaps calling another macro.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2015 16:09:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286208#M2509</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-10-21T16:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass multiple values from a search as parameters to a macro so the macro will be run for each value?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286209#M2510</link>
      <description>&lt;P&gt;This was helpfull however my situation is a bit different &lt;/P&gt;

&lt;P&gt;my marcro:&lt;BR /&gt;
eval FLAG=if(isnull($Parameter$),0,1) | eval TYPE="$Parameter$" | stats sum(FLAG)  as COUNT by TYPE, sourcetype, REPORT_TIME&lt;/P&gt;

&lt;P&gt;so on my list there are 8 different values. Every value go to the macro into 2 places ($parameter$) and give the result then another value go into 2 places and result and so on. &lt;/P&gt;

&lt;P&gt;| mymacro(parameter) |&lt;/P&gt;

&lt;P&gt;Is it posible to do that ?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2015 08:15:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286209#M2510</guid>
      <dc:creator>akawacz</dc:creator>
      <dc:date>2015-10-22T08:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass multiple values from a search as parameters to a macro so the macro will be run for each value?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286210#M2511</link>
      <description>&lt;P&gt;I do not understand your term &lt;CODE&gt;list&lt;/CODE&gt;.   Are you saying that &lt;CODE&gt;parameter&lt;/CODE&gt; is a multi-valued field with 8 values?  Maybe you should give example data (with fields).&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2015 13:05:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286210#M2511</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-10-22T13:05:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass multiple values from a search as parameters to a macro so the macro will be run for each value?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286211#M2512</link>
      <description>&lt;P&gt;I want to get my list from search if possible. It will be 8 column names. If not I can maybe use CSV file and use inputlookup command&lt;/P&gt;

&lt;P&gt;Then I want to add one column name at the time run a macro then add another and run a macro. At the end result will be comined. &lt;/P&gt;

&lt;P&gt;example data:&lt;BR /&gt;
Name&lt;BR /&gt;
ID&lt;BR /&gt;
ect&lt;/P&gt;

&lt;P&gt;hope this help&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2015 15:28:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286211#M2512</guid>
      <dc:creator>akawacz</dc:creator>
      <dc:date>2015-10-22T15:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass multiple values from a search as parameters to a macro so the macro will be run for each value?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286212#M2513</link>
      <description>&lt;P&gt;OK, then!  That is different.  Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | foreach * [`mymacro(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)`]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Oct 2015 17:11:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286212#M2513</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-10-22T17:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass multiple values from a search as parameters to a macro so the macro will be run for each value?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286213#M2514</link>
      <description>&lt;P&gt;I think with your hint I am closer to solution however I have encounter further issues.Results are not combined into one. It is showing last result&lt;/P&gt;

&lt;P&gt;It looks that my macro does not work properly.&lt;BR /&gt;
eval FLAG=if(isnull($Parameter$),0,1) | eval TYPE="$Parameter$" | stats sum(FLAG) as COUNT by TYPE, sourcetype, REPORT_TIME&lt;/P&gt;

&lt;P&gt;Once I am testing without macro and put brackets ]  after second &lt;BR /&gt;
eval expression - i have got result for one filed.  Once I put them at the end I got error message.&lt;BR /&gt;
...... | foreach IM_* [eval FLAG=if(isnull(&amp;lt;&amp;gt;),0,1)]|stats sum(ERR_FLAG)  as ERR_COUNT by  sourcetype, REPORT_PERIOD&lt;/P&gt;

&lt;P&gt;Foreach can not deal with Text.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:43:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286213#M2514</guid>
      <dc:creator>akawacz</dc:creator>
      <dc:date>2020-09-29T07:43:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass multiple values from a search as parameters to a macro so the macro will be run for each value?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286214#M2515</link>
      <description>&lt;P&gt;I see that you asked another question related to this and I am as confused on that one as I am on this one.  We are working too much on a particular solution path without understanding the entire problem.  Let's back ALL THE WAY UP and get a firm foundation.  Show a minimal sample data set and then show a mock-up of the desired output.  I am sure we will be able to help you.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2015 15:03:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286214#M2515</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-10-26T15:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass multiple values from a search as parameters to a macro so the macro will be run for each value?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286215#M2516</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
Thank you for helping me here&lt;BR /&gt;
As you probably see I have managed to solve my issue in a bit different way (second my question ) but here I wanted use a macro for that. &lt;/P&gt;

&lt;P&gt;So basically I wanted check how many values are populated in the filed for couple of different columns. &lt;/P&gt;

&lt;P&gt;E.g. Column ASSIGNEE for some different months have different counts for populated filed&lt;BR /&gt;
Sep- 100 Nov -200 vs all events is 1000. So Sep- is 10% and Nov 20% of populated values in the filed ASSIGNE&lt;/P&gt;

&lt;P&gt;I was going to do a macro which will be populated one column at a time. &lt;BR /&gt;
E.g. first time ASSIGNE later another column name and so on. &lt;BR /&gt;
For this reason I have transformed column headers into value&lt;BR /&gt;
index=test_im | stats dc(IM*) as IM* | transpose| fields column |&lt;/P&gt;

&lt;P&gt;Then I was planing use one column put to  the macro using FOREACH command &lt;/P&gt;

&lt;P&gt;My idea was:&lt;/P&gt;

&lt;P&gt;index=test_im | stats dc(IM*) as IM* | transpose| fields column &lt;BR /&gt;
| foreach * [&lt;CODE&gt;mymacro(&amp;lt;&amp;gt;)&lt;/CODE&gt;]&lt;/P&gt;

&lt;P&gt;Macro: will populate &amp;lt;&amp;gt;  with columns (like ASSIGNEE later another coulmn and so on. )At the end result will be combined &lt;BR /&gt;
my macro:&lt;BR /&gt;
eval FLAG=if(isnull($Parameter$),0,1) | eval TYPE="$Parameter$" | stats sum(FLAG) as COUNT by TYPE, sourcetype, REPORT_TIME&lt;/P&gt;

&lt;P&gt;Sorry for not good expalanation. Just starting with Splunk and want to explore a lot of new commands.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:43:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286215#M2516</guid>
      <dc:creator>akawacz</dc:creator>
      <dc:date>2020-09-29T07:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass multiple values from a search as parameters to a macro so the macro will be run for each value?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286216#M2517</link>
      <description>&lt;P&gt;Just post your final answer to both questions and then click "Accept" to close them both.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2015 17:31:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286216#M2517</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-10-26T17:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass multiple values from a search as parameters to a macro so the macro will be run for each value?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286217#M2518</link>
      <description>&lt;P&gt;I have Accepted second question. Here Macro is still not working for me. &lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2015 10:44:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/286217#M2518</guid>
      <dc:creator>akawacz</dc:creator>
      <dc:date>2015-10-27T10:44:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass multiple values from a search as parameters to a macro so the macro will be run for each value?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/654118#M9650</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/1406"&gt;@woodcock&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when you are saying&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;| foreach * [`mymacro(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)`]&lt;/PRE&gt;&lt;P&gt;what is the value of a * ? I am tryin gto use macro twice in my search, but not working&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2023 17:57:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-pass-multiple-values-from-a-search-as-parameters-to-a/m-p/654118#M9650</guid>
      <dc:creator>yvassilyeva</dc:creator>
      <dc:date>2023-08-11T17:57:11Z</dc:date>
    </item>
  </channel>
</rss>

