<?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: Log files with different Time Formats in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433958#M1458</link>
    <description>&lt;P&gt;Please see the start of this thread.  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I am stuck with this:  Jun 18, 11:36:08.131667&lt;BR /&gt;
and I feel it will cause issues moving forward.&lt;BR /&gt;
Regards,&lt;BR /&gt;
Dave&lt;/P&gt;</description>
    <pubDate>Wed, 19 Jun 2019 18:02:02 GMT</pubDate>
    <dc:creator>dowdag</dc:creator>
    <dc:date>2019-06-19T18:02:02Z</dc:date>
    <item>
      <title>Log files with different Time Formats</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433953#M1453</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have several log files that use this Date Time format: &lt;CODE&gt;2019-06-18 11:34:15,205&lt;/CODE&gt;&lt;BR /&gt;However one log file does not: &lt;CODE&gt;Jun 18, 11:36:08.131667&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;Should I be using "Field Transforms" to change the TimeStamp to a UNIX style...&lt;BR /&gt;Would you do this at the time file is uploaded or Indexed?&lt;/P&gt;
&lt;P&gt;I can accomplish is inline but what is 'best practices' ?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;| rex field=TimeStamp "(?&amp;lt;Month&amp;gt;\w+)"
| lookup MonthStrToNum MonthAbrv as Month OUTPUT MonthNumber
| rex field=TimeStamp "\w+\s(?&amp;lt;Day&amp;gt;\d+)"
| eval year=strftime(now(), "%Y") 
| rex field=TimeStamp "^.+,\s(?&amp;lt;Time&amp;gt;[\d:.]+)"
| eval DateTimeStr=strftime(strptime (year . "-". MonthNumber . "-" . Day ." " . Time, "%Y-%m-%d %H:%M:%S,%6N"), "%Y-%m-%d %H:%M:%S,%3N")
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;using _time is not options as I want to look TimeStamps in log file and not the _time it was indexed.&lt;/P&gt;
&lt;P&gt;Thanks for any suggestions!&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2020 16:09:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433953#M1453</guid>
      <dc:creator>dowdag</dc:creator>
      <dc:date>2020-06-10T16:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: Log files with different Time Formats</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433954#M1454</link>
      <description>&lt;P&gt;can you elaborate?&lt;BR /&gt;
what is the problem you are trying to solve?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 02:31:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433954#M1454</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2019-06-19T02:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: Log files with different Time Formats</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433955#M1455</link>
      <description>&lt;P&gt;Hi @dowdag,&lt;/P&gt;

&lt;P&gt;If you're using the same sourcetype for both files then your approach will work well.&lt;/P&gt;

&lt;P&gt;However, if you have the possibility to split into multiple sourcetype that would preferable. You'll then be able to leverage time extraction at index time and it will also make it easier for you to extract and manage fields for each type of data files.&lt;/P&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
David&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 02:49:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433955#M1455</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-06-19T02:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: Log files with different Time Formats</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433956#M1456</link>
      <description>&lt;P&gt;I am using different source types for each type of log file. What I was asking is if I can an inline transformation as the time data is feeding into splunk.&lt;BR /&gt;
Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 15:34:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433956#M1456</guid>
      <dc:creator>dowdag</dc:creator>
      <dc:date>2019-06-19T15:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Log files with different Time Formats</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433957#M1457</link>
      <description>&lt;P&gt;oh, yeah in that case it's totally possible. Your query seems good. You can also apply the extractions on index time if needed, but that won't apply on already existing logs.&lt;BR /&gt;
If you like go ahead and post the format you have in &lt;CODE&gt;TimeStamps&lt;/CODE&gt; and what you would like it to look like and I can see if there is any room for improving your query.&lt;BR /&gt;
Cheers!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 17:11:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433957#M1457</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-06-19T17:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: Log files with different Time Formats</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433958#M1458</link>
      <description>&lt;P&gt;Please see the start of this thread.  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I am stuck with this:  Jun 18, 11:36:08.131667&lt;BR /&gt;
and I feel it will cause issues moving forward.&lt;BR /&gt;
Regards,&lt;BR /&gt;
Dave&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 18:02:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433958#M1458</guid>
      <dc:creator>dowdag</dc:creator>
      <dc:date>2019-06-19T18:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: Log files with different Time Formats</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433959#M1459</link>
      <description>&lt;P&gt;So if this : &lt;CODE&gt;Jun 18, 11:36:08.131667&lt;/CODE&gt; is your &lt;CODE&gt;TimeStamp&lt;/CODE&gt; field. You can replace the entire logic above with this for inline :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval DateTimeStr=strftime(strptime(TimeStamp,"%b %d, %H:%M:%S,%6N"), "%Y-%m-%d %H:%M:%S,%3N")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can also use TIME_FORMAT at index time and set it as &lt;CODE&gt;%b %d, %H:%M:%S,%6N&lt;/CODE&gt;it will avoid you having to run any time formatting command.&lt;/P&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
David&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 19:46:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433959#M1459</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-06-19T19:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: Log files with different Time Formats</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433960#M1460</link>
      <description>&lt;P&gt;David,&lt;/P&gt;

&lt;P&gt;I am doing what you suggested .&lt;/P&gt;

&lt;P&gt;#field extraction&lt;BR /&gt;
    ^(?P&lt;TIMESTAMP&gt;\w+\s+\d+,\s+\d+:\d+:\d+.\d+)(?:[^ \n]* ){4}(?P&lt;TRANSID&gt;[^,]+),\s\w+-\d+\s\"(?P&lt;INFO&gt;.+)\"&lt;/INFO&gt;&lt;/TRANSID&gt;&lt;/TIMESTAMP&gt;&lt;/P&gt;

&lt;P&gt;Source type is correct, however TimeStamp  is still pulling back &lt;BR /&gt;
    Jun 06, 11:11:35.754855  &lt;/P&gt;

&lt;P&gt;The converted version that is in '_time' is correct!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| table _time TimeStamp 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But the hour field is offset -1 in '_time'  and I have been told it is best not to use _time.&lt;/P&gt;

&lt;P&gt;What did I miss?  &lt;/P&gt;

&lt;P&gt;Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 20:55:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433960#M1460</guid>
      <dc:creator>dowdag</dc:creator>
      <dc:date>2019-06-19T20:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: Log files with different Time Formats</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433961#M1461</link>
      <description>&lt;P&gt;Just to be sure I understand you, could you confirm this check list is good :&lt;BR /&gt;
1- _time is being extracted as &lt;CODE&gt;Jun 18, 11:36:08.131667&lt;/CODE&gt; but with 1 hour offset. Possibly due to your user timezone.&lt;BR /&gt;
2- TimeStamp is extracted properly.&lt;BR /&gt;
3- The eval expression I gave you works well and gives you the right time.&lt;/P&gt;

&lt;P&gt;Give me a yes/no for 1,2 &amp;amp; 3.&lt;/P&gt;

&lt;P&gt;I have a feeling that all what your missing is a props.conf configuration to get _time in the right TZ then you can use _time instead of all that hassle.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 21:31:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433961#M1461</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-06-19T21:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: Log files with different Time Formats</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433962#M1462</link>
      <description>&lt;P&gt;Yes  to 1,2,3!  So I cleared out all data and starting fresh.&lt;BR /&gt;
There still is confusion on why someone would advice not to use _time,&lt;/P&gt;

&lt;P&gt;My  goal is to convert: &lt;BR /&gt;
    Jun 18, 11:36:08.131667&lt;BR /&gt;
    ^(?P&lt;TIMESTAMP&gt;\w+\s+\d+,\s+\d+:\d+:\d+.\d+) &lt;BR /&gt;
when data is uploaded or forwarded into splunk,&lt;/TIMESTAMP&gt;&lt;/P&gt;

&lt;P&gt;When I defined the source type I did  use this &lt;BR /&gt;
    "%b %d, %H:%M:%S,%6N" - and I do see timestamp selected correctly in the Set Source Type dialog and Time zone is set to my local computer.&lt;BR /&gt;
Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 22:09:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433962#M1462</guid>
      <dc:creator>dowdag</dc:creator>
      <dc:date>2019-06-19T22:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: Log files with different Time Formats</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433963#M1463</link>
      <description>&lt;P&gt;Always use _time when possible, its way more efficient to use that compared to field extraction or a calculated field. &lt;/P&gt;

&lt;P&gt;Last step for you is to set the right TZ to avoid that hour offset. So you should have in your &lt;CODE&gt;props.conf&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[YourSourcetype]
....
TIME_FORMAT = %b %d, %H:%M:%S,%6N
TZ= &amp;lt;POSIX time zone string&amp;gt;
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope that helps !&lt;BR /&gt;
And please upvote and accept if its helpful!&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2019 04:27:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433963#M1463</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-06-20T04:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: Log files with different Time Formats</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433964#M1464</link>
      <description>&lt;P&gt;Hi David,&lt;/P&gt;

&lt;P&gt;Thanks for your help... still a little unclear on how everything works.&lt;BR /&gt;
I have set the timezone on my source types to CST and my VM instance has it's timezone set to CST. Now I read somewhere that splunk converts data to be indexed to UTC....  but when I import data and run a query &lt;BR /&gt;
 &lt;CODE&gt;|table _time TimeStamp&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;no mater what source type it is _time is always an hour earlier. &amp;lt;&amp;gt; &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; TIME_FORMAT = %b %d, %H:%M:%S,%6N
 TZ= &amp;lt;POSIX time zone string&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can you provide a literal string example of what you mean by &lt;/P&gt;

&lt;P&gt;Also in Source Type under TimeStamp / Advanced &lt;BR /&gt;
what does the Timestamp prefix do.  I have seen just a &lt;CODE&gt;^&lt;/CODE&gt; but sure what this is doing....  any examples are appreciated.... &lt;BR /&gt;
Thanks!&lt;BR /&gt;
Dave Gilden / Ft. Worth Tx&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2019 21:47:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Log-files-with-different-Time-Formats/m-p/433964#M1464</guid>
      <dc:creator>dowdag</dc:creator>
      <dc:date>2019-06-20T21:47:21Z</dc:date>
    </item>
  </channel>
</rss>

