Splunk Search

Sorting by TimeStamps in events with Multiple TimeStamps

cramasta
Builder

Hi, So I have a flat log file that i am indexing that has two timestamps in the same format. I don't care which one gets recognized as the timestamp by Splunk but what I do want to be able to do is sort by either timestamp. Currently I can sort correctly by the timestamp that splunk picks up as being the events timestamp. However when i try and sort by the other timestamp column it does not work correctly and mixes the dates up. It comes close to being correctly sorted but not 100%.

format of the logs

"9/27/2010 5:23:39 AM","7/20/2010 1:48:28 PM",MBX01-SG20-DB20

My temp work around is to do this

| eval NewTime = strptime(NonRecognizedTimeStamp, "%m/%d/%Y %H:%M:%S %p")

what this does is gives me a new column called NewTime that converts the timestamp into a numerical format like 1279636323.000000 which i can then sort, and in return, sorts the NonRecognizedTimeStamp column correctly.

Is there a way that i can get the other timestamp to be recognized correctly or at least have my temp solution return the NewTime Column in the %m/%d/%Y %H:%M:%S format. Thanks, Joe

Tags (1)
1 Solution

gkanapathy
Splunk Employee
Splunk Employee

What you're doing is really the only way for you to sort by the non-indexed timestamp, unless you can, e.g., change your log format.

View solution in original post

0 Karma

gkanapathy
Splunk Employee
Splunk Employee

What you're doing is really the only way for you to sort by the non-indexed timestamp, unless you can, e.g., change your log format.

0 Karma
Get Updates on the Splunk Community!

.conf24 | Day 0

Hello Splunk Community! My name is Chris, and I'm based in Canberra, Australia's capital, and I travelled for ...

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

(view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...