Splunk Enterprise

Sort a date in string format.

abhishekroy168
Path Finder

hi
My requirement is to create a graph for incident vs time and sort them according to my field opened_at.
But while sorting what i observe is it sorts only by one thing,either year or month or date.
So now i have dates as Mar 2015,Feb,2018,Feb 2015,March 2016.
I want the sorted form as Mar 2015,Feb,2015,March 2016, Feb 2018.alt text

Thank you

Tags (1)
0 Karma

somesoni2
Revered Legend

Move your time formatting after the stats command

Replace

... | eval time=strftime(time,"%b %Y") | stats  count(number) by time

With

... | stats  count(number) by time | eval time=strftime(time,"%b %Y") 

The time was in epoch format, so it'll sort correctly. You can just format it to user friendly after stats so sorting is maintained. With strftime invoke earlier, the timestamp is converted to string and sorting is done alphabetically not chronologically.

0 Karma

abhishekroy168
Path Finder

hey somesoni2
Thanks for replying my query.
I had already tried the solution which you gave ... | stats count(number) by time | eval time=strftime(time,"%b %Y")
issue with this is the incidents gets grouped by day not month.
Like earlier all the incidents for a given month were in same bar but now there are individual bars for every day.
I need to group it by months.

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...