<?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 extract an event timestamp where seconds and milliseconds are concatenated without padded zeros? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-an-event-timestamp-where-seconds-and-milliseconds/m-p/428837#M75142</link>
    <description>&lt;P&gt;Starting with Splunk 7.2 its possible to do some eval operations during index time using INGEST_EVAL attribute in transforms.conf and applying them to the source type in question.&lt;BR /&gt;
So, in this case we can do the following configuration:&lt;/P&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[get_sec_msec]
REGEX = ^(?:\d+,){5}(?&amp;lt;sec_msec&amp;gt;\d+),
FORMAT = sec_msec::$1
WRITE_META = true

[eval_sec]
INGEST_EVAL = _time=round(_time+(sec_msec/1000),3)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[your_sourcetype]
TRANSFORMS-evalingest = get_sec_msec, eval_sec
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Explanation:&lt;BR /&gt;
The approach I used was to extract the number in indextime and, using INGEST_EVAL, divide it by 1000 and adding it to _time.&lt;/P&gt;

&lt;P&gt;Example&lt;BR /&gt;
2019,8,6,9,31,1234,event data&lt;BR /&gt;
the correct extraction would be 1 sec and 234 msec&lt;BR /&gt;
1234/1000 = 1.234&lt;BR /&gt;
_time = _time + 1.234&lt;/P&gt;

&lt;P&gt;I use the round to force the value to add the .234. Testing I've done regarding this, if I didn't use the round(_time,3) I  ended up only with the sec added and not the msec.&lt;/P&gt;</description>
    <pubDate>Tue, 06 Aug 2019 13:15:02 GMT</pubDate>
    <dc:creator>diogofgm</dc:creator>
    <dc:date>2019-08-06T13:15:02Z</dc:date>
    <item>
      <title>How to extract an event timestamp where seconds and milliseconds are concatenated without padded zeros?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-an-event-timestamp-where-seconds-and-milliseconds/m-p/428836#M75141</link>
      <description>&lt;P&gt;I came across a weird log format where the seconds and milliseconds are concatenated without padded zeros.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Example data&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2019,8,6,9,31,1,event data
2019,8,6,9,31,12,event data
2019,8,6,9,31,123,event data
2019,8,6,9,31,1234,event data
2019,8,6,9,31,12345,event data
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Problem&lt;/STRONG&gt;&lt;BR /&gt;
From my testing TIME_FORMAT doesn't work correctly in this case. It would if this number had padded zeros (e.g 00012)&lt;BR /&gt;
Formats I tested and the results&lt;BR /&gt;
%Y,%m,%d,%H,%M,%S%3N - works on the 5 digit but not the others since they show the wrong amount of seconds&lt;BR /&gt;
%Y,%m,%d,%H,%M,%S - same as before, in most cases it shows the wrong amount of seconds&lt;BR /&gt;
%Y,%m,%d,%H,%M,%5N - doesn't extract anything after the minutes&lt;/P&gt;

&lt;P&gt;How can I solve this without building a custom input or pre-processing the data before indexing it?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 13:07:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-an-event-timestamp-where-seconds-and-milliseconds/m-p/428836#M75141</guid>
      <dc:creator>diogofgm</dc:creator>
      <dc:date>2019-08-06T13:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract an event timestamp where seconds and milliseconds are concatenated without padded zeros?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-an-event-timestamp-where-seconds-and-milliseconds/m-p/428837#M75142</link>
      <description>&lt;P&gt;Starting with Splunk 7.2 its possible to do some eval operations during index time using INGEST_EVAL attribute in transforms.conf and applying them to the source type in question.&lt;BR /&gt;
So, in this case we can do the following configuration:&lt;/P&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[get_sec_msec]
REGEX = ^(?:\d+,){5}(?&amp;lt;sec_msec&amp;gt;\d+),
FORMAT = sec_msec::$1
WRITE_META = true

[eval_sec]
INGEST_EVAL = _time=round(_time+(sec_msec/1000),3)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[your_sourcetype]
TRANSFORMS-evalingest = get_sec_msec, eval_sec
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Explanation:&lt;BR /&gt;
The approach I used was to extract the number in indextime and, using INGEST_EVAL, divide it by 1000 and adding it to _time.&lt;/P&gt;

&lt;P&gt;Example&lt;BR /&gt;
2019,8,6,9,31,1234,event data&lt;BR /&gt;
the correct extraction would be 1 sec and 234 msec&lt;BR /&gt;
1234/1000 = 1.234&lt;BR /&gt;
_time = _time + 1.234&lt;/P&gt;

&lt;P&gt;I use the round to force the value to add the .234. Testing I've done regarding this, if I didn't use the round(_time,3) I  ended up only with the sec added and not the msec.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 13:15:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-extract-an-event-timestamp-where-seconds-and-milliseconds/m-p/428837#M75142</guid>
      <dc:creator>diogofgm</dc:creator>
      <dc:date>2019-08-06T13:15:02Z</dc:date>
    </item>
  </channel>
</rss>

