<?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 Formatting timestamp field extracted from CSV file for post processing in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Formatting-timestamp-field-extracted-from-CSV-file-for-post/m-p/684700#M114228</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm currently ingesting CSV files to Splunk. One of the fields record actual Event Timestamp in this format YYYYmmddHHMMSS (e.g. 20240418142025). I need to format this field's value in a way that Splunk will understand the data (e.g. date, hour, minutes, second etc.). Once this formatting is complete, I need to sort these time stamps/events for each Second (e.g. bucket span=1s Event_Time). Note here Event_Time is the formatted data from original Event Timestamp field.&lt;/P&gt;
&lt;P&gt;So far, I've tried this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=test1 sourcetype=test2 | eval Event_Time=strftime(strptime(SUBMIT_TIME,"%Y%m%d%H%M%S"), "%m/%d/%y %H:%M:%S") | table Event_Time&lt;/LI-CODE&gt;
&lt;P&gt;Above command gives me decent output such as 04/18/24 14:20:25.&lt;/P&gt;
&lt;P&gt;But, when I try to group values of Event_Time using "bucket span=1s Event_Time", it does not do anything. Note that "bucket span=1s _time" works as I'm using Splunk default time field.&lt;/P&gt;
&lt;P&gt;Appreciate any help to make this formatting work for post processing Event_Time.&lt;/P&gt;
&lt;P&gt;Thank you in advance.&lt;/P&gt;</description>
    <pubDate>Thu, 18 Apr 2024 19:02:47 GMT</pubDate>
    <dc:creator>gaurav10</dc:creator>
    <dc:date>2024-04-18T19:02:47Z</dc:date>
    <item>
      <title>Formatting timestamp field extracted from CSV file for post processing</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Formatting-timestamp-field-extracted-from-CSV-file-for-post/m-p/684700#M114228</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm currently ingesting CSV files to Splunk. One of the fields record actual Event Timestamp in this format YYYYmmddHHMMSS (e.g. 20240418142025). I need to format this field's value in a way that Splunk will understand the data (e.g. date, hour, minutes, second etc.). Once this formatting is complete, I need to sort these time stamps/events for each Second (e.g. bucket span=1s Event_Time). Note here Event_Time is the formatted data from original Event Timestamp field.&lt;/P&gt;
&lt;P&gt;So far, I've tried this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=test1 sourcetype=test2 | eval Event_Time=strftime(strptime(SUBMIT_TIME,"%Y%m%d%H%M%S"), "%m/%d/%y %H:%M:%S") | table Event_Time&lt;/LI-CODE&gt;
&lt;P&gt;Above command gives me decent output such as 04/18/24 14:20:25.&lt;/P&gt;
&lt;P&gt;But, when I try to group values of Event_Time using "bucket span=1s Event_Time", it does not do anything. Note that "bucket span=1s _time" works as I'm using Splunk default time field.&lt;/P&gt;
&lt;P&gt;Appreciate any help to make this formatting work for post processing Event_Time.&lt;/P&gt;
&lt;P&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2024 19:02:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Formatting-timestamp-field-extracted-from-CSV-file-for-post/m-p/684700#M114228</guid>
      <dc:creator>gaurav10</dc:creator>
      <dc:date>2024-04-18T19:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting timestamp field extracted from CSV file for post processing</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Formatting-timestamp-field-extracted-from-CSV-file-for-post/m-p/684704#M114229</link>
      <description>&lt;P&gt;In order to bin the Event time, you need to keep it as a number (after parsing with strptime). You can format it as a string later or use fieldformat for display purposes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=test1 sourcetype=test2 | eval Event_Time=strptime(SUBMIT_TIME,"%Y%m%d%H%M%S") | table Event_Time
``` This next line is redundant since you only have Event_Time to the nearest second anyway ```
| bin Event_Time span=1s
| sort 0 Event_Time
| fieldformat Event_Time=strftime(Event_Time, "%m/%d/%y %H:%M:%S")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2024 19:49:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Formatting-timestamp-field-extracted-from-CSV-file-for-post/m-p/684704#M114229</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-04-18T19:49:34Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting timestamp field extracted from CSV file for post processing</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Formatting-timestamp-field-extracted-from-CSV-file-for-post/m-p/684711#M114230</link>
      <description>&lt;P&gt;Ading to &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt; 's answer - ideally you should have your main time field for a given event parsed on ingestion to the &lt;EM&gt;_time&lt;/EM&gt; field so that Splunk can effectively search your data and "organize it" timewise.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2024 20:32:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Formatting-timestamp-field-extracted-from-CSV-file-for-post/m-p/684711#M114230</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-04-18T20:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting timestamp field extracted from CSV file for post processing</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Formatting-timestamp-field-extracted-from-CSV-file-for-post/m-p/684817#M114255</link>
      <description>&lt;P&gt;Thank you &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;. I used your recommended query as below but unable to get any output:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=test1 sourcetype=test2 EVENT A | bin Event_Time span=1s | sort 0 Event_Time | fieldformat Event_Time=strftime(Event_Time, "%m/%d/%y %H:%M:%S")&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;Please see below my old Splunk query being used using Splunk default "_time" field.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=test1 sourcetype=test2 EVENT A | bucket span=1s _time | stats count AS EventPerSec by _time | timechart span=1d max(EventPerSec)&lt;/LI-CODE&gt;
&lt;P&gt;Ultimately, in this query, I want to replace "_time" by "Event_Time" that is more accurate than "_time".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that there can be multiple events in my data occurring at the exact same time (to the Seconds value). So basically, my query find the peak "EventPerSec" value in 1 day.&lt;/P&gt;
&lt;P&gt;Hope this explanation helps.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2024 18:19:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Formatting-timestamp-field-extracted-from-CSV-file-for-post/m-p/684817#M114255</guid>
      <dc:creator>gaurav10</dc:creator>
      <dc:date>2024-04-19T18:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting timestamp field extracted from CSV file for post processing</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Formatting-timestamp-field-extracted-from-CSV-file-for-post/m-p/684853#M114267</link>
      <description>&lt;P&gt;That doesn't appear to be what I recommended - perhaps that's why you are not getting any results?&lt;/P&gt;&lt;P&gt;It would help if you could share some sample anonymised events so we can see what it is that you are dealing with and try to figure a search that will work for you, because just discussing searches without knowing what they apply to is often fruitless.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Apr 2024 07:28:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Formatting-timestamp-field-extracted-from-CSV-file-for-post/m-p/684853#M114267</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-04-20T07:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting timestamp field extracted from CSV file for post processing</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Formatting-timestamp-field-extracted-from-CSV-file-for-post/m-p/684865#M114271</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/267087"&gt;@gaurav10&lt;/a&gt;&amp;nbsp;Note that in &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;'s solution, Event_Time is handled in 2 steps, with the binning in between:&lt;/P&gt;&lt;P&gt;First, convert SUBMIT_TIME to a time field using strptime.&lt;/P&gt;&lt;P&gt;Now you can bin based on a time span. Do your binning in this in-between phase.&lt;/P&gt;&lt;P&gt;Second, convert the new Event_Time to a string using strftime.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Apr 2024 13:35:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Formatting-timestamp-field-extracted-from-CSV-file-for-post/m-p/684865#M114271</guid>
      <dc:creator>P_vandereerden</dc:creator>
      <dc:date>2024-04-20T13:35:54Z</dc:date>
    </item>
  </channel>
</rss>

