<?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 now() Inside Map Command? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Any-examples-of-using-now-inside-map-command/m-p/647658#M224151</link>
    <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;now&lt;/FONT&gt; function always returns the time the search started.&amp;nbsp; There is no provision for doing otherwise.&lt;/P&gt;&lt;P&gt;To get the time for each event ("loop"), use the &lt;FONT face="courier new,courier"&gt;time&lt;/FONT&gt; function.&lt;/P&gt;</description>
    <pubDate>Tue, 20 Jun 2023 17:17:47 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2023-06-20T17:17:47Z</dc:date>
    <item>
      <title>Any examples of using now() inside map command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Any-examples-of-using-now-inside-map-command/m-p/647644#M224149</link>
      <description>&lt;P&gt;It appears that using now() inside of the map command will always return the time that the map was started rather than the time for each loop. The below SPL shows an example of this. Does anyone have any thoughts on how to get the time for each iteration of the loop?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| makeresults count=100
| map maxsearches=100 search="| makeresults count=1
| eval outer_time=$_time$
| eval outer_time_formatted=strftime($_time$, \"%Y-%m-%d %H:%M:%S\")
| eval now=now()"
| table outer_time_formatted outer_time _time now&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 01:29:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Any-examples-of-using-now-inside-map-command/m-p/647644#M224149</guid>
      <dc:creator>fredclown</dc:creator>
      <dc:date>2023-06-22T01:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: Using now() Inside Map Command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Any-examples-of-using-now-inside-map-command/m-p/647657#M224150</link>
      <description>&lt;P&gt;Do you need now()? Doesn't _time hold now?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=100
| map maxsearches=100 search="| makeresults count=1
| eval inner_time=_time"&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 20 Jun 2023 17:17:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Any-examples-of-using-now-inside-map-command/m-p/647657#M224150</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-06-20T17:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: Using now() Inside Map Command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Any-examples-of-using-now-inside-map-command/m-p/647658#M224151</link>
      <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;now&lt;/FONT&gt; function always returns the time the search started.&amp;nbsp; There is no provision for doing otherwise.&lt;/P&gt;&lt;P&gt;To get the time for each event ("loop"), use the &lt;FONT face="courier new,courier"&gt;time&lt;/FONT&gt; function.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2023 17:17:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Any-examples-of-using-now-inside-map-command/m-p/647658#M224151</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-06-20T17:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: Using now() Inside Map Command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Any-examples-of-using-now-inside-map-command/m-p/647817#M224191</link>
      <description>&lt;P&gt;I was using makeresults as a simplified example to show the behavior. My real SPL is using the rest command inside the map. There is no _time with results returned from | rest. I'm trying to get the time the rest command was started for each iteration of the loop. My hunch is this is not possible.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2023 15:26:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Any-examples-of-using-now-inside-map-command/m-p/647817#M224191</guid>
      <dc:creator>fredclown</dc:creator>
      <dc:date>2023-06-21T15:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: Using now() Inside Map Command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Any-examples-of-using-now-inside-map-command/m-p/647818#M224192</link>
      <description>&lt;P&gt;The example I gave is a simplified one to show the behavior. My real SPL has the | rest command inside the map. The | rest command does not return _time. I am trying to figure out the time the rest command started for each iteration of the loop. My hunch is this isn't possible.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2023 15:29:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Any-examples-of-using-now-inside-map-command/m-p/647818#M224192</guid>
      <dc:creator>fredclown</dc:creator>
      <dc:date>2023-06-21T15:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using now() Inside Map Command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Any-examples-of-using-now-inside-map-command/m-p/647822#M224193</link>
      <description>&lt;P&gt;My answer referred to the &lt;FONT face="courier new,courier"&gt;time&lt;/FONT&gt; function, not the _time field.&amp;nbsp; You should be able to use &lt;FONT face="courier new,courier"&gt;time()&lt;/FONT&gt; to get the time of each &lt;FONT face="courier new,courier"&gt;rest&lt;/FONT&gt; call.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2023 15:48:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Any-examples-of-using-now-inside-map-command/m-p/647822#M224193</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-06-21T15:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using now() Inside Map Command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Any-examples-of-using-now-inside-map-command/m-p/647824#M224194</link>
      <description>&lt;P&gt;I am confused. &amp;nbsp;As&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;pointed out, &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/DateandTimeFunctions#time.28.29" target="_blank" rel="noopener"&gt;time()&lt;/A&gt; is the correct function to use (in lieu of now()) inside a loop if you want to reveal the time of each iteration. &amp;nbsp;Does this not work? &amp;nbsp;It certainly works for me. (9.0.4)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=100
| map maxsearches=100 search="| makeresults count=1
| eval outer_time=$_time$
| eval outer_time_formatted=strftime($_time$, \"%Y-%m-%d %H:%M:%S\")
| eval now=time()"
| table outer_time_formatted outer_time _time now&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;outer_time_formatted&lt;/TD&gt;&lt;TD&gt;outer_time&lt;/TD&gt;&lt;TD&gt;_time&lt;/TD&gt;&lt;TD&gt;now&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2023-06-21 08:44:16&lt;/TD&gt;&lt;TD&gt;1687362256&lt;/TD&gt;&lt;TD&gt;2023-06-21 08:44:16&lt;/TD&gt;&lt;TD&gt;1687362256.312381&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2023-06-21 08:44:16&lt;/TD&gt;&lt;TD&gt;1687362256&lt;/TD&gt;&lt;TD&gt;2023-06-21 08:44:16&lt;/TD&gt;&lt;TD&gt;1687362256.404865&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2023-06-21 08:44:16&lt;/TD&gt;&lt;TD&gt;1687362256&lt;/TD&gt;&lt;TD&gt;2023-06-21 08:44:16&lt;/TD&gt;&lt;TD&gt;1687362256.476129&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2023-06-21 08:44:16&lt;/TD&gt;&lt;TD&gt;1687362256&lt;/TD&gt;&lt;TD&gt;2023-06-21 08:44:16&lt;/TD&gt;&lt;TD&gt;1687362256.546069&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2023-06-21 08:44:16&lt;/TD&gt;&lt;TD&gt;1687362256&lt;/TD&gt;&lt;TD&gt;2023-06-21 08:44:16&lt;/TD&gt;&lt;TD&gt;1687362256.616955&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2023-06-21 08:44:16&lt;/TD&gt;&lt;TD&gt;1687362256&lt;/TD&gt;&lt;TD&gt;2023-06-21 08:44:16&lt;/TD&gt;&lt;TD&gt;1687362256.690642&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2023-06-21 08:44:16&lt;/TD&gt;&lt;TD&gt;1687362256&lt;/TD&gt;&lt;TD&gt;2023-06-21 08:44:16&lt;/TD&gt;&lt;TD&gt;1687362256.772683&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 21 Jun 2023 15:50:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Any-examples-of-using-now-inside-map-command/m-p/647824#M224194</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-06-21T15:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: Using now() Inside Map Command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Any-examples-of-using-now-inside-map-command/m-p/647840#M224196</link>
      <description>&lt;P&gt;Oh, goodness! I was not aware of the time() function. That's what I was looking for. Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2023 18:39:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Any-examples-of-using-now-inside-map-command/m-p/647840#M224196</guid>
      <dc:creator>fredclown</dc:creator>
      <dc:date>2023-06-21T18:39:04Z</dc:date>
    </item>
  </channel>
</rss>

