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!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...