Splunk Search

how to take timestamp from this

gajananh999
Contributor

Dear all,

I need your help to how to remove timestamp from this field.

2014-05-19T03:25:26.000-04:00

There is TO word in this so i want to remove that and remove the last -04:00 also.

Can anybody help me on this on regular expression?

Thanks

Gajanan Hiroji

Tags (2)
0 Karma

gajananh999
Contributor

This is my log file

Timestamp   Event
5/22/14 10:32:15.000 AM [2014-05-22T05:02:15.000+00:00] [oracle] [NOTIFICATION:1] [] [] [ecid: 00^sq] [tid: 1604]  [36007] Loading repository.

Here it show Timestamp 5/22/14 10:32:15.000 AM But the actual timestamp is 2014-05-22T05:02:15.000+00:00 which should be 5/22/14 05:02:15.000 AM exactly 5.30 hours it is increasing for all the event what may be the reason behind this?

Thanks

Gajanan Hiroji

0 Karma

lcrielaa
Communicator

Depends on what you're looking for but here's some examples:

Regex capture group for date and time

^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}\.\d{3})-\d{2}:\d{2}

Splunk rex command for extracting date and time

| rex field=_raw ^(?<Date>\d{4}-\d{2}-\d{2})T(?<Time>\d{2}:\d{2}:\d{2}\.\d{3})-\d{2}:\d{2}

In props.conf, you'll want something like TIME_FORMAT=%Y-%m-%dT%H:%M:%S.%3N

Also, there isn't a word "TO" in there, it's just the letter T and the zero. It's not the letter O.

gajananh999
Contributor

This is my log file

Timestamp   Event
5/22/14 10:32:15.000 AM [2014-05-22T05:02:15.000+00:00] [oracle] [NOTIFICATION:1] [] [] [ecid: 00^sq] [tid: 1604]  [36007] Loading repository.

Here it show Timestamp 5/22/14 10:32:15.000 AM But the actual timestamp is 2014-05-22T05:02:15.000+00:00 which should be 5/22/14 05:02:15.000 AM exactly 5.30 hours it is increasing for all the event what may be the reason behind this?

Thanks

Gajanan Hiroji

0 Karma

gajananh999
Contributor

But when i try to do field extract with the same Regex it shows Regex does not extract any named fields. I tried removing last part of regex that is -\d{2}:\d{2} because it was not required for me. Am I going wrong somewhere?

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...