Splunk Search

help for sorting time

jip31
Motivator

hello

I use a time field like this but I am unable to sort the time with descending sort

How to do this please?

| eval time = strftime(_time, "%m/%d/%Y %H:%M") 
| rename time as "Event time" 
| table "Event time" 
| sort "Event time"

 

Tags (1)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @jip31,

to sort time fields you have to convert them in epochtime.

In your case, _time is already in epochtime so you have only to change the order of your commands:

| sort -_time
| eval "Event time" = strftime(_time, "%m/%d/%Y %H:%M") 
| table "Event time" 

 Ciao.

Giuseppe

View solution in original post

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @jip31,

to sort time fields you have to convert them in epochtime.

In your case, _time is already in epochtime so you have only to change the order of your commands:

| sort -_time
| eval "Event time" = strftime(_time, "%m/%d/%Y %H:%M") 
| table "Event time" 

 Ciao.

Giuseppe

0 Karma

jip31
Motivator

Thanks Giuseppe

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @jip31,

good for you.

ciao and happy splunking.

Giuseppe

P.S.: Karma Points are appreciated 😉

0 Karma
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 ...