Splunk Search

regex help for timestamp extraction from event log

rakesh_498115
Motivator

Hi,

PFB My Sample log event .

Its has two timestamps in it , which are highlighted. i need to create two regexs to pick these values.

Sample log :

2013-07-02 12:39:39.991 ddl02773xx07 10.187.151.10 61011 20130702|http://www.bt.com/ccc/mdd/WA/|W28A|OrderDetails|Corsica|null|SA03|null|null|null|955|8006**|12:39:39... FASTPETE,UniqueID=0702106723570554,threadID=2ncr9uj5w0,busTxnSys=FASTPETE,busTxnHdr=PCK01069,busTxnType=FASTPETE,busProcOriginator=TAA

i.e first timestamp should come in field say startTime and second timestamp in field sat endTime

for the above log the values should be like this ,
startTime = 12:39:39:812
endTime = 12:39:39.991

can any one pls help in creating these two fields ??

I have used regex for startTime like this

rex "|(?\d{2}:\d{2}:\d{2}.\d{3})|" this is giving a field startTime . but unable to get the second timestamp as endTime.. any clue for getting second field ?

Tags (1)
0 Karma

linu1988
Champion

|rex "(?i)(?P\d+:\d+:\d+.\d+|\d+:\d+:\d+.\d+)|" |eval t=split(temp,"|")|eval starttime=mvindex(t,0)|eval endtime=mvindex(t,1)|table starttime,endtime. Another approach...

0 Karma

MuS
SplunkTrust
SplunkTrust

Hi rakesh_498115

I'm sure there is a better way, but as a quick shot I figured this out:

 (\|(\d{2}:\d{2}:\d{2}\.\d{3})){1}\|(?<myField>(\d{2}:\d{2}:\d{2}\.\d{3}))

cheers, MuS

Get Updates on the Splunk Community!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...