<?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: Using $starttime$ and $endtime$ in a macro with 'map' in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Using-starttime-and-endtime-in-a-macro-with-map/m-p/34823#M7580</link>
    <description>&lt;P&gt;No joy, still gives the same error :-(. Thanks though.&lt;/P&gt;</description>
    <pubDate>Thu, 16 May 2013 14:00:16 GMT</pubDate>
    <dc:creator>phemmer</dc:creator>
    <dc:date>2013-05-16T14:00:16Z</dc:date>
    <item>
      <title>Using $starttime$ and $endtime$ in a macro with 'map'</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-starttime-and-endtime-in-a-macro-with-map/m-p/34819#M7576</link>
      <description>&lt;P&gt;I am trying to create a macro which uses &lt;CODE&gt;$startime$&lt;/CODE&gt; and &lt;CODE&gt;$endtime$&lt;/CODE&gt; in a &lt;CODE&gt;map&lt;/CODE&gt;. Whenever I do however I get the following error:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Error in 'map': Did not find value for required attribute 'starttime'.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also this only happens if I specify a search time frame such as "Last 15 minutes". If I specify a custom time frame with specific beginning and end it works.&lt;/P&gt;

&lt;P&gt;Here is the macro:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$search$ | localize timebefore=10s timeafter=10s | map search="search ( ($search$) OR ($filter$) ) starttimeu=$starttime$ endtimeu=$endtime$" | eval _raw=strftime(_time, "%T")." - "._raw | transaction maxpause=10s
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The parameters are &lt;CODE&gt;search&lt;/CODE&gt; and &lt;CODE&gt;filter&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Additionally when I run the macro by hand, substituting the parameters, it works.&lt;/P&gt;

&lt;P&gt;For example, this fails:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;`surrounding("status&amp;gt;=500 status&amp;lt;=599", "error")`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But this works:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;status&amp;gt;=500 status&amp;lt;=599 | localize timebefore=10s timeafter=10s | map search="search ( (status&amp;gt;=500 status&amp;lt;=599) OR (error) ) starttimeu=$starttime$ endtimeu=$endtime$" | eval _raw=strftime(_time, "%T")." - "._raw | transaction maxpause=10s
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 May 2013 15:31:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-starttime-and-endtime-in-a-macro-with-map/m-p/34819#M7576</guid>
      <dc:creator>phemmer</dc:creator>
      <dc:date>2013-05-15T15:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using $starttime$ and $endtime$ in a macro with 'map'</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-starttime-and-endtime-in-a-macro-with-map/m-p/34820#M7577</link>
      <description>&lt;P&gt;you are not passing $starttime$ and $endtime$ as arguments in macro call...&lt;/P&gt;

&lt;P&gt;-Kamal Bisht&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2013 06:09:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-starttime-and-endtime-in-a-macro-with-map/m-p/34820#M7577</guid>
      <dc:creator>kml_uvce</dc:creator>
      <dc:date>2013-05-16T06:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using $starttime$ and $endtime$ in a macro with 'map'</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-starttime-and-endtime-in-a-macro-with-map/m-p/34821#M7578</link>
      <description>&lt;P&gt;You are correct, because they are not arguments. See documentation on &lt;CODE&gt;map&lt;/CODE&gt; and &lt;CODE&gt;localize&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2013 12:22:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-starttime-and-endtime-in-a-macro-with-map/m-p/34821#M7578</guid>
      <dc:creator>phemmer</dc:creator>
      <dc:date>2013-05-16T12:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using $starttime$ and $endtime$ in a macro with 'map'</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-starttime-and-endtime-in-a-macro-with-map/m-p/34822#M7579</link>
      <description>&lt;P&gt;When I had to pass a field through to the map command like this (&lt;EM&gt;note:&lt;/EM&gt; as part of saved search!), I had to double the dollar signs:  &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;
| inputlookup monitored_indexes.csv| fields index | dedup index | map maxsearches=99 search=" | &lt;CODE&gt;db_inspect_collection($$index$$)&lt;/CODE&gt;"&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Maybe doubling the dollar signs can help you?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:55:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-starttime-and-endtime-in-a-macro-with-map/m-p/34822#M7579</guid>
      <dc:creator>sowings</dc:creator>
      <dc:date>2020-09-28T13:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: Using $starttime$ and $endtime$ in a macro with 'map'</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-starttime-and-endtime-in-a-macro-with-map/m-p/34823#M7580</link>
      <description>&lt;P&gt;No joy, still gives the same error :-(. Thanks though.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2013 14:00:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-starttime-and-endtime-in-a-macro-with-map/m-p/34823#M7580</guid>
      <dc:creator>phemmer</dc:creator>
      <dc:date>2013-05-16T14:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: Using $starttime$ and $endtime$ in a macro with 'map'</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-starttime-and-endtime-in-a-macro-with-map/m-p/34824#M7581</link>
      <description>&lt;P&gt;Unrelated, but that worked for me when adding a map command (with substitutions) to a dashboard. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2018 20:04:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-starttime-and-endtime-in-a-macro-with-map/m-p/34824#M7581</guid>
      <dc:creator>reed_kelly</dc:creator>
      <dc:date>2018-06-25T20:04:40Z</dc:date>
    </item>
  </channel>
</rss>

