<?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 How to set the timestamp when using the collect command? in Knowledge Management</title>
    <link>https://community.splunk.com/t5/Knowledge-Management/How-to-set-the-timestamp-when-using-the-collect-command/m-p/292438#M2570</link>
    <description>&lt;P&gt;I am searching yesterday's data and trying to insert it into an index for reporting purposes. I need to take multiple indexed events with various date/time fields and override them with the current date/time for the summary index table. The following search is a very simplified version that illustrates the issue.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=blah

| eval _time=now()
| collect index=test

&lt;/LI-CODE&gt;
&lt;P&gt;When I do the search, it inserts yesterday's date/time into the summary index _time field. Is there any way to reassign this?&lt;/P&gt;
&lt;P&gt;Splunk 6.6.3.&lt;/P&gt;</description>
    <pubDate>Tue, 03 Sep 2024 18:06:20 GMT</pubDate>
    <dc:creator>regriffith</dc:creator>
    <dc:date>2024-09-03T18:06:20Z</dc:date>
    <item>
      <title>How to set the timestamp when using the collect command?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-set-the-timestamp-when-using-the-collect-command/m-p/292438#M2570</link>
      <description>&lt;P&gt;I am searching yesterday's data and trying to insert it into an index for reporting purposes. I need to take multiple indexed events with various date/time fields and override them with the current date/time for the summary index table. The following search is a very simplified version that illustrates the issue.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=blah

| eval _time=now()
| collect index=test

&lt;/LI-CODE&gt;
&lt;P&gt;When I do the search, it inserts yesterday's date/time into the summary index _time field. Is there any way to reassign this?&lt;/P&gt;
&lt;P&gt;Splunk 6.6.3.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2024 18:06:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-set-the-timestamp-when-using-the-collect-command/m-p/292438#M2570</guid>
      <dc:creator>regriffith</dc:creator>
      <dc:date>2024-09-03T18:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: Setting the timestamp when using the collect command</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-set-the-timestamp-when-using-the-collect-command/m-p/292439#M2571</link>
      <description>&lt;P&gt;When you pipe events to &lt;CODE&gt;collect&lt;/CODE&gt; with the &lt;CODE&gt;_raw&lt;/CODE&gt; field present, that field will be used as the only value that gets indexed, and &lt;CODE&gt;_time&lt;/CODE&gt; will be parsed from that text.&lt;/P&gt;

&lt;P&gt;If you want to set your own &lt;CODE&gt;_time&lt;/CODE&gt;, I suggest including only the fields you want and need in your summary index, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=blah | table user http_uri | eval _time=now() | collect index=test
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Edit:&lt;/P&gt;

&lt;P&gt;you &lt;EM&gt;could&lt;/EM&gt; remove the old timestamp from the lines and insert a new one, but I would consider that a poor choice, as you're altering what was previously evidentiary quality data&lt;/P&gt;

&lt;P&gt;Or perhaps you could collect the event with &lt;CODE&gt;_raw&lt;/CODE&gt; in a new field.  Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=blah | eval orig_raw=_raw | eval _time=now() | table _time orig_raw | collect index=test
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Jan 2018 22:28:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-set-the-timestamp-when-using-the-collect-command/m-p/292439#M2571</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-01-09T22:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: Setting the timestamp when using the collect command</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-set-the-timestamp-when-using-the-collect-command/m-p/292440#M2572</link>
      <description>&lt;P&gt;Maybe &lt;CODE&gt;| collect index=test addtime=true&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2018 23:06:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-set-the-timestamp-when-using-the-collect-command/m-p/292440#M2572</guid>
      <dc:creator>ddrillic</dc:creator>
      <dc:date>2018-01-09T23:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: Setting the timestamp when using the collect command</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-set-the-timestamp-when-using-the-collect-command/m-p/292441#M2573</link>
      <description>&lt;P&gt;The docs suggest this would use &lt;CODE&gt;info_min_time&lt;/CODE&gt; first, if present (which it sounds like it would be), and is true by default anyway:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;addtime
Syntax: addtime=&amp;lt;bool&amp;gt;
Description: Use this option to specify whether to prefix a time field on to each event. Some commands return results that do not have a _raw field, such as the stats, chart, timechart commands. If you specify addtime=false, the Splunk software uses its generic date detection against fields in whatever order they happen to be in the summary rows. If you specify addtime=true, the Splunk software uses the search time range info_min_time. This time range is added by the sistats) command or _time. Splunk software adds the time field based on the first field that it finds: info_min_time, _time, or now().
Default: true
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Jan 2018 23:21:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-set-the-timestamp-when-using-the-collect-command/m-p/292441#M2573</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-01-09T23:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: Setting the timestamp when using the collect command</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-set-the-timestamp-when-using-the-collect-command/m-p/292442#M2574</link>
      <description>&lt;P&gt;hey&lt;BR /&gt;
you can set the value of the _time field before the collect.&lt;/P&gt;

&lt;P&gt;Example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | addinfo | eval _time=info_max_time | collect index=test
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;you can use any eval function to calculate the _time value.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2018 05:22:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-set-the-timestamp-when-using-the-collect-command/m-p/292442#M2574</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-01-10T05:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: Setting the timestamp when using the collect command</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-set-the-timestamp-when-using-the-collect-command/m-p/577117#M8618</link>
      <description>&lt;P&gt;So i figured out a way to retain _time. Whatever you are bringing over into your summary index; source, sourcetype, fields of your choice....Create your own _raw field. In my instance I created _raw as below:&lt;BR /&gt;| eval _raw= _time. ":" .source&lt;BR /&gt;| table _raw ALL OTHER FIELDS YOU WANT&lt;BR /&gt;| collect index=SI&lt;BR /&gt;&lt;BR /&gt;This will retain the _time value in your summary index. If this works for you please upvote this response!&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2021 18:33:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-set-the-timestamp-when-using-the-collect-command/m-p/577117#M8618</guid>
      <dc:creator>adobrzeniecki</dc:creator>
      <dc:date>2021-12-02T18:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: Setting the timestamp when using the collect command</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-set-the-timestamp-when-using-the-collect-command/m-p/607496#M8956</link>
      <description>&lt;P&gt;It's working! But you need to use addtime=false and Splunk taking first timestamp in your event.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 09:40:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-set-the-timestamp-when-using-the-collect-command/m-p/607496#M8956</guid>
      <dc:creator>aliuwkina</dc:creator>
      <dc:date>2022-07-29T09:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to set the timestamp when using the collect command?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-set-the-timestamp-when-using-the-collect-command/m-p/698088#M10282</link>
      <description>&lt;P&gt;wow. my problem was this snippet works ONLY when i put "T" in the timeformat.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| eval _time=strptime(time2, "%Y-%m-%dT%H:%M:%S.%3N")&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 03 Sep 2024 15:52:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-set-the-timestamp-when-using-the-collect-command/m-p/698088#M10282</guid>
      <dc:creator>highsplunker</dc:creator>
      <dc:date>2024-09-03T15:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to set the timestamp when using the collect command?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-set-the-timestamp-when-using-the-collect-command/m-p/698125#M10283</link>
      <description>&lt;P&gt;This is a thread from so long ago and is about a long forgotten version.&lt;/P&gt;&lt;P&gt;Nowadays collect is much more flexible, especially if you're using output_format=hec&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2024 17:48:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-set-the-timestamp-when-using-the-collect-command/m-p/698125#M10283</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-09-03T17:48:24Z</dc:date>
    </item>
  </channel>
</rss>

