<?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: Unable to parse macro name from map command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Unable-to-parse-macro-name-from-map-command/m-p/413334#M119165</link>
    <description>&lt;P&gt;thanks.  this works.  I like the &lt;CODE&gt;[]&lt;/CODE&gt; syntax better so I don't have to escape the double quotes, but this will do.  the dropdown is dynamically created so unfortunately I need the map.&lt;/P&gt;

&lt;P&gt;Do I have to add a |s suffix to other internal variables (e.g. $var|s$) so user input of var will have its double quotes escaped?&lt;/P&gt;</description>
    <pubDate>Tue, 22 Jan 2019 14:06:27 GMT</pubDate>
    <dc:creator>weidertc</dc:creator>
    <dc:date>2019-01-22T14:06:27Z</dc:date>
    <item>
      <title>Unable to parse macro name from map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Unable-to-parse-macro-name-from-map-command/m-p/413332#M119163</link>
      <description>&lt;P&gt;I have a lookup table with a field that contains a macro name.  the rows returned from the lookup table dictate which macro needs to run based on the user selection of an input dropdown.  I need to get the query to parse the macro and then run the search.&lt;/P&gt;

&lt;P&gt;I'm open to different way to accomplish this, but the docs claim map command can do this.&lt;/P&gt;

&lt;P&gt;test.csv&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;id, name
1, macro1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;query&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup test.csv | map [`$name$`] maxsearches=10000
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get no results.  It is going in a dashboard too, so i put &lt;CODE&gt;$$name$$&lt;/CODE&gt; there, and i get nothing.  I tried using the other map syntax using "" instead of [], but everything to no avail.&lt;/P&gt;

&lt;P&gt;How can I accomplish this?&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jan 2019 15:57:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Unable-to-parse-macro-name-from-map-command/m-p/413332#M119163</guid>
      <dc:creator>weidertc</dc:creator>
      <dc:date>2019-01-18T15:57:28Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to parse macro name from map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Unable-to-parse-macro-name-from-map-command/m-p/413333#M119164</link>
      <description>&lt;P&gt;@weidertc,&lt;/P&gt;

&lt;P&gt;Below works with a macro in a dashboard&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;     &amp;lt;search&amp;gt;
        &amp;lt;query&amp;gt;|inputlookup macro.csv |where id=$macro$|table name|map search="search `$$name$$`"&amp;lt;/query&amp;gt;
     &amp;lt;/search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Based on the user selection, one of the macros is selected and run the search defined in the macro&lt;/P&gt;

&lt;H2&gt;XML&lt;/H2&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;MACROS&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="dropdown" token="macro"&amp;gt;
      &amp;lt;label&amp;gt;Macro&amp;lt;/label&amp;gt;
      &amp;lt;choice value="1"&amp;gt;1&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="2"&amp;gt;2&amp;lt;/choice&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;|inputlookup macro.csv |where id=$macro$|table name|map search="search `$$name$$`"&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-15m&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Alternatively, if you dont have a large number of macros, you could directly add them to the dropdown or load it to the dropdown from lookup and use the macro name directly instead using a &lt;CODE&gt;map&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;MACROS&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="dropdown" token="macro"&amp;gt;
      &amp;lt;label&amp;gt;Macro&amp;lt;/label&amp;gt;
      &amp;lt;choice value="internal"&amp;gt;1&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="introspection"&amp;gt;2&amp;lt;/choice&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;`$macro$`&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-15m&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 Jan 2019 05:11:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Unable-to-parse-macro-name-from-map-command/m-p/413333#M119164</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-01-19T05:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to parse macro name from map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Unable-to-parse-macro-name-from-map-command/m-p/413334#M119165</link>
      <description>&lt;P&gt;thanks.  this works.  I like the &lt;CODE&gt;[]&lt;/CODE&gt; syntax better so I don't have to escape the double quotes, but this will do.  the dropdown is dynamically created so unfortunately I need the map.&lt;/P&gt;

&lt;P&gt;Do I have to add a |s suffix to other internal variables (e.g. $var|s$) so user input of var will have its double quotes escaped?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 14:06:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Unable-to-parse-macro-name-from-map-command/m-p/413334#M119165</guid>
      <dc:creator>weidertc</dc:creator>
      <dc:date>2019-01-22T14:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to parse macro name from map command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Unable-to-parse-macro-name-from-map-command/m-p/583432#M203165</link>
      <description>&lt;P&gt;If you're not using a dashboard, this solution will work.&lt;/P&gt;&lt;P&gt;The map command cannot parse macros passed to it; however, it can use its own macro with a parameter and parse spl passed to it, even if the spl is a macro.&lt;/P&gt;&lt;P&gt;This does not work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;| makeresults count=1
| eval Search="`searchMacro`"
| map search="search $Search$ earliest=@h-1h latest=@m" maxsearches=10&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;| makeresults count=1
| eval Search="`searchMacro`"
| map search="search `Map($Search$)` earliest=@h-1h latest=@m" maxsearches=10&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You will have to make the Map(1) macro which will function only as a pass-through.&lt;/P&gt;&lt;P&gt;in macro `Map(1)`, set Definition=$map$; Arguments=map.&amp;nbsp; That's it.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 17:02:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Unable-to-parse-macro-name-from-map-command/m-p/583432#M203165</guid>
      <dc:creator>weidertc</dc:creator>
      <dc:date>2022-02-02T17:02:28Z</dc:date>
    </item>
  </channel>
</rss>

