<?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 Best way to extract _time from file name and text in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Best-way-to-extract-time-from-file-name-and-text/m-p/676764#M113186</link>
    <description>&lt;P&gt;Hello to everyone!&lt;BR /&gt;I have a curious situation:&lt;BR /&gt;I have log files that I collecting via SplunkUF&lt;BR /&gt;This log file does not contain a whole timestamp - one part of the timestamp is contained in the file name, and the other is placed directly in the event&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;As I found in the other answers, I have options.&lt;BR /&gt;1. INGEST_EVAL on the indexer layer: I did not understand how I could take one part from the source and glue it with _raw data&lt;BR /&gt;&lt;A href="https://community.splunk.com/t5/Getting-Data-In/How-to-use-date-in-filename-as-the-timestamp-for-each-event/m-p/240175" target="_self"&gt;Link to the answer&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;2. Use handmade script to create a valid timestamp for events - this is more understandable for me, but it looks like "reinventing the wheel"&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;So the question is, may I use the first option if it is possible?&lt;BR /&gt;This is the an example of the source:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;E:\logs\rmngr_*\24020514.log

* - some number
24 - Year
Month - 02
Day - 04
Hour - 14&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;And this is an example of the event:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;45:50.152011-0,CONN,3,process=rmngr,p:processName=RegMngrCntxt,p:processName=ServerJobExecutorContext,OSThread=15348,t:clientID=64658,t:applicationName=ManagerProcess,t:computerName=hostname01,Txt=Clnt: DstUserName1: user@domain.com StartProtocol: 0 Success

45:50.152011 - Minute, Second and Subsecond&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 06 Feb 2024 16:34:29 GMT</pubDate>
    <dc:creator>NoSpaces</dc:creator>
    <dc:date>2024-02-06T16:34:29Z</dc:date>
    <item>
      <title>Best way to extract _time from file name and text</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Best-way-to-extract-time-from-file-name-and-text/m-p/676764#M113186</link>
      <description>&lt;P&gt;Hello to everyone!&lt;BR /&gt;I have a curious situation:&lt;BR /&gt;I have log files that I collecting via SplunkUF&lt;BR /&gt;This log file does not contain a whole timestamp - one part of the timestamp is contained in the file name, and the other is placed directly in the event&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;As I found in the other answers, I have options.&lt;BR /&gt;1. INGEST_EVAL on the indexer layer: I did not understand how I could take one part from the source and glue it with _raw data&lt;BR /&gt;&lt;A href="https://community.splunk.com/t5/Getting-Data-In/How-to-use-date-in-filename-as-the-timestamp-for-each-event/m-p/240175" target="_self"&gt;Link to the answer&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;2. Use handmade script to create a valid timestamp for events - this is more understandable for me, but it looks like "reinventing the wheel"&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;So the question is, may I use the first option if it is possible?&lt;BR /&gt;This is the an example of the source:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;E:\logs\rmngr_*\24020514.log

* - some number
24 - Year
Month - 02
Day - 04
Hour - 14&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;And this is an example of the event:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;45:50.152011-0,CONN,3,process=rmngr,p:processName=RegMngrCntxt,p:processName=ServerJobExecutorContext,OSThread=15348,t:clientID=64658,t:applicationName=ManagerProcess,t:computerName=hostname01,Txt=Clnt: DstUserName1: user@domain.com StartProtocol: 0 Success

45:50.152011 - Minute, Second and Subsecond&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 16:34:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Best-way-to-extract-time-from-file-name-and-text/m-p/676764#M113186</guid>
      <dc:creator>NoSpaces</dc:creator>
      <dc:date>2024-02-06T16:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: Best way to extract _time from file name and text</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Best-way-to-extract-time-from-file-name-and-text/m-p/677156#M113231</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;you could look my old post&amp;nbsp;&lt;A href="https://community.splunk.com/t5/Getting-Data-In/How-to-apply-source-file-date-using-INGEST-as-Time/m-p/596865" target="_blank"&gt;https://community.splunk.com/t5/Getting-Data-In/How-to-apply-source-file-date-using-INGEST-as-Time/m-p/596865&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;You need to do small modifications to it.&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Select correct format into 1st replace part to get year to hour part from source.&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;Replace tostring part with take your minutes to sub second from _raw e.g. substring/replace&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;modify format string to match your combined year to sub second format&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;You could test this like I have done on above post. If needed, don’t hesitate to ask more help.&lt;/P&gt;&lt;P&gt;Remember that INGEST_EVAL must be an one command only.&lt;/P&gt;&lt;P&gt;r. Ismo&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2024 18:00:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Best-way-to-extract-time-from-file-name-and-text/m-p/677156#M113231</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2024-02-09T18:00:03Z</dc:date>
    </item>
    <item>
      <title>Re: Best way to extract _time from file name and text</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Best-way-to-extract-time-from-file-name-and-text/m-p/677542#M113272</link>
      <description>&lt;P&gt;After a lot of tries, I finally did it&lt;BR /&gt;Looks simple when you know what to do&lt;BR /&gt;Thank you for advertising the substr function &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The final result is below&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;props.conf&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[oce_file_rphost]
TRANSFORMS-oce_file_tc0 = oce_file_tc0
LINE_BREAKER = ()\d{2}:\d{2}.\d+-\d+,
SHOULD_LINEMERGE = false&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;transform.conf&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[oce_file_tc0]
INGEST_EVAL = _time = strptime("20" + replace(source,".*\\\\(\d{8}).log","\1") + substr(_raw,0,12),"%Y%m%d%H%M:%S.%6Q")&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2024 09:49:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Best-way-to-extract-time-from-file-name-and-text/m-p/677542#M113272</guid>
      <dc:creator>NoSpaces</dc:creator>
      <dc:date>2024-02-14T09:49:34Z</dc:date>
    </item>
  </channel>
</rss>

