<?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 combine year, month, day from a filename and contain the exact time of the event in nanoseconds? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267420#M51210</link>
    <description>&lt;P&gt;I think the problem is that %s represents Epoch time, not seconds since midnight. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; %s The Unix Epoch Time timestamp, or the number of seconds since the Epoch: 1970-01-01 00:00:00 +0000 (UTC). (1352395800 is Thu Nov 8 09:30:00 2012)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So Splunk is grabbing 10  digits for epoch, ie 6273371272.  And that resolves to GMT: Mon, 17 Oct 2168 11:07:52.&lt;/P&gt;

&lt;P&gt;I don't think there is a common time format variable that represents seconds since midnight.&lt;/P&gt;</description>
    <pubDate>Thu, 20 Oct 2016 23:06:00 GMT</pubDate>
    <dc:creator>maciep</dc:creator>
    <dc:date>2016-10-20T23:06:00Z</dc:date>
    <item>
      <title>How to combine year, month, day from a filename and contain the exact time of the event in nanoseconds?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267416#M51206</link>
      <description>&lt;P&gt;I need to ingest a file that contains the year, month, and day in the filename, while also containing the exact time of the event (since midnight) within the day inside the file, in a field called nanos. I'm trying to figure out the best way to get a combination of these two pieces of information to get the correct _time field.&lt;/P&gt;

&lt;P&gt;Sample file:&lt;BR /&gt;
Filename: test_csv_parsing_20161011.txt&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sequenceNumber,nanos,msgType,poolId,accountId,fixMsgType,fixData
29585650,62733712723932,'*',zzzz,zzzz,54,''
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Given the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;nanos =&amp;gt; seconds =&amp;gt; hours:mins:secs.nanos
62733712723932 =&amp;gt; 62733.712723932 =&amp;gt; 17:25:33.712723932
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Expected results:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time = 2016/10/11 17:25:33.712723932
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have already tried the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;TIME_FORMAT=%s%9N
TIMESTAMP_FIELDS=nanos
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Based on what it says in the &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.0/Data/HowSplunkextractstimestamps" target="_blank"&gt;configure timestamps Splunk docs&lt;/A&gt;, it should take the date from the filename if it can only find the time inside the event: "4. If no events in a source have a date, Splunk software tries to find a date in the source name or file name. Time of day is not identified in filenames. (This requires that the events have a time, even though they don't have a date.)"&lt;/P&gt;

&lt;P&gt;But I get the following warnings in the "adddata/datapreview" dashboard: "&lt;CODE&gt;The TIME_FORMAT specified is matching timestamps (Mon Oct 17 07:07:52 2168) outside of the acceptable time window. If this timestamp is correct, consider adjusting MAX_DAYS_AGO and MAX_DAYS_HENCE.&lt;/CODE&gt;" &amp;amp; "&lt;CODE&gt;Failed to parse timestamp. Defaulting to file modtime.&lt;/CODE&gt;"&lt;/P&gt;

&lt;P&gt;It's probably because it's giving the %s priority over the %9N in the TIME_FORMAT. If it first captured the last 9 digits as nanoseconds, and then used the rest as seconds this should work.&lt;/P&gt;

&lt;P&gt;Can anybody provide guidance?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:31:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267416#M51206</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2020-09-29T11:31:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine year, month, day from a filename and contain the exact time of the event in nanoseconds?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267417#M51207</link>
      <description>&lt;P&gt;what does your entire props stanza look like for this sourcetype?  are you using indexed_extractions?  &lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 21:15:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267417#M51207</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2016-10-20T21:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine year, month, day from a filename and contain the exact time of the event in nanoseconds?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267418#M51208</link>
      <description>&lt;P&gt;Yes I am&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[ csv ]
CHARSET=UTF-8
INDEXED_EXTRACTIONS=csv
KV_MODE=none
SHOULD_LINEMERGE=false
category=Structured
description=Comma-separated value format. Set header and other settings in "Delimited Settings"
disabled=false
pulldown_type=true
TIME_FORMAT=%s%9N
FIELD_NAMES=sequenceNumber,nanos,msgType,poolId,accountId,fixMsgType,fixData
TIMESTAMP_FIELDS=nanos
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Oct 2016 21:37:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267418#M51208</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2016-10-20T21:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine year, month, day from a filename and contain the exact time of the event in nanoseconds?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267419#M51209</link>
      <description>&lt;P&gt;oh and is that configured on your forwarder or indexer or elsewhere?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 22:05:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267419#M51209</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2016-10-20T22:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine year, month, day from a filename and contain the exact time of the event in nanoseconds?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267420#M51210</link>
      <description>&lt;P&gt;I think the problem is that %s represents Epoch time, not seconds since midnight. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; %s The Unix Epoch Time timestamp, or the number of seconds since the Epoch: 1970-01-01 00:00:00 +0000 (UTC). (1352395800 is Thu Nov 8 09:30:00 2012)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So Splunk is grabbing 10  digits for epoch, ie 6273371272.  And that resolves to GMT: Mon, 17 Oct 2168 11:07:52.&lt;/P&gt;

&lt;P&gt;I don't think there is a common time format variable that represents seconds since midnight.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 23:06:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267420#M51210</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2016-10-20T23:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine year, month, day from a filename and contain the exact time of the event in nanoseconds?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267421#M51211</link>
      <description>&lt;P&gt;I did something similar but it was a little bit tricky. &lt;/P&gt;

&lt;P&gt;In my case the source field is "/root/test_csv_parsing_20161011.txt" then I extracted a new field called &lt;STRONG&gt;newdate&lt;/STRONG&gt; from metadata "source" like this in the props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EXTRACT-newdate=\/.*?\/.*?\_(?P&amp;lt;newdate&amp;gt;\d+)\..* in source
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then you can concat the fields and send to another index with "collect" command with the new _time field:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=proof | eval seconds=round(nanos*0.000000001) |eval newseconds=strftime(seconds,"%H%M%S") | eval newtimestamp=newdate.newseconds | eval c_time=strptime(newtimestamp,"%Y%m%d%H%M%S") |eval _time=c_time | eval _raw=_time + ": " + _raw | collect index=mynewindex 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Maybe this is not the cleanest way to do it but I'm sure it can help you. &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:31:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267421#M51211</guid>
      <dc:creator>jrballesteros05</dc:creator>
      <dc:date>2020-09-29T11:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine year, month, day from a filename and contain the exact time of the event in nanoseconds?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267422#M51212</link>
      <description>&lt;P&gt;You'll need to customize datetime.xml to parse out the date from filename&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/172535/extract-date-time-from-source-path-with-custom-dat.html"&gt;https://answers.splunk.com/answers/172535/extract-date-time-from-source-path-with-custom-dat.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2016 14:54:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267422#M51212</guid>
      <dc:creator>tchen_splunk</dc:creator>
      <dc:date>2016-10-21T14:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine year, month, day from a filename and contain the exact time of the event in nanoseconds?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267423#M51213</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/48424"&gt;@jrballesteros05&lt;/a&gt; &lt;/P&gt;

&lt;P&gt;Thanks for your reply, but I was hoping to get the _time field properly extracted from the very start. I will attempt &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/72223"&gt;@tchen_splunk&lt;/a&gt; 's solution, and if that doesn't work I'll give your search time solution a try.&lt;/P&gt;

&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:35:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267423#M51213</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2020-09-29T11:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine year, month, day from a filename and contain the exact time of the event in nanoseconds?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267424#M51214</link>
      <description>&lt;P&gt;Thanks @tchen_splunk - I'll give this solution a try and mark it correct if it works.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2016 14:06:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267424#M51214</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2016-10-25T14:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine year, month, day from a filename and contain the exact time of the event in nanoseconds?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267425#M51215</link>
      <description>&lt;P&gt;Unfortunately this doesn't seem to work.&lt;/P&gt;

&lt;P&gt;A bug report has been submitted to follow up.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2016 17:32:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267425#M51215</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2016-11-02T17:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine year, month, day from a filename and contain the exact time of the event in nanoseconds?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267426#M51216</link>
      <description>&lt;P&gt;I tried all the answers online and my own way of fix things, i ended up coming up with nothing that works. I ended up using eval to extract the filedate from source. &lt;/P&gt;

&lt;P&gt;FYI &lt;/P&gt;

&lt;P&gt;I don't know how this line worked for him &lt;BR /&gt;
 EXTRACT-newdate=\/.&lt;EM&gt;?\/.&lt;/EM&gt;?_(?P\d+)..* in source&lt;/P&gt;

&lt;P&gt;but i had to go to transforms.conf to get that working.&lt;/P&gt;

&lt;P&gt;props.conf&lt;BR /&gt;
REPORT-filedate= tranName&lt;/P&gt;

&lt;P&gt;transforms.conf&lt;BR /&gt;
[tranName]&lt;BR /&gt;
blah blah&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2016 14:49:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-combine-year-month-day-from-a-filename-and-contain-the/m-p/267426#M51216</guid>
      <dc:creator>moaf13</dc:creator>
      <dc:date>2016-11-04T14:49:26Z</dc:date>
    </item>
  </channel>
</rss>

