Getting Data In

timestamp extraction for time format with leading zero omitted in the event

alextsui
Path Finder

Hi, I would like to extract timestamp from events where the leading zeros of the time format are omitted. Most of the events have the time format like the example below, where Splunk is able to extract the correct time for the events to be 2010/03/22 11:59:49 pm.

20100322,235949,1=1,52=M2010032223594908434,11=192.168.99.132,2=20

However the leading zeros in the time format are omitted. For exmaple "20100322,314,..." means 2010/03/22 00:03:14 am.

Splunk extracts incorrectly for the following event sample to 2010/03/22 10:05:08 pm. The correct time for the event below should be 2010/03/22 02:20:58 am:

20100322,22058,1=1,110=250 U2M2Kv0225593 Message accepted

At the extreme end, events with 5 omitted leading zeros in the time format like 20100322,1,1=1,...., and it's timestamp should be 2010/03/22 00:00:01 am.

What's best way to extract such time format from the events? If it involves modifying the datetime.xml, please kindly provide the REGEX.

Thanks.

Tags (1)

dwaddle
SplunkTrust
SplunkTrust

I'm not sure this is possible. Parsing is difficult when there is ambiguity - would a time of "1111" be 00:11:11, 11:11:00 or 01:01:01?

In my opinion, this is the type of problem where for the sake of your own sanity you are far better off to try to get the source application fixed to where it either delimits Hour, Minute, Second, Subsecond or 0-fills appropriately.

Get Updates on the Splunk Community!

Unlock Database Monitoring with Splunk Observability Cloud

  In today’s fast-paced digital landscape, even minor database slowdowns can disrupt user experiences and ...

Purpose in Action: How Splunk Is Helping Power an Inclusive Future for All

At Cisco, purpose isn’t a tagline—it’s a commitment. Cisco’s FY25 Purpose Report outlines how the company is ...

[Upcoming Webinar] Demo Day: Transforming IT Operations with Splunk

Join us for a live Demo Day at the Cisco Store on January 21st 10:00am - 11:00am PST In the fast-paced world ...