Splunk Search

issue regarding date_wday

elaine0102
Explorer

| stats count by date_wday |

Hi all, above return me Friday, Monday, Saturday, Sunday, Thursday, Tuesday, Wednesday.

How can I make it to display : Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday ?

Tags (1)
0 Karma

gkanapathy
Splunk Employee
Splunk Employee

It would be a lot better to do:

... | timechart span=1d count by _time

or

... | bucket span=1d _time | stats count by _time

sdaniels
Splunk Employee
Splunk Employee

The first thing you'll use is time modifiers depending on when you are searching. For example earliest=@w1 would snap to Monday of the current week. Check it out because depending on when you do the search you'll want to control what days you are looking at.

http://docs.splunk.com/Documentation/Splunk/4.2.3/SearchReference/SearchTimeModifiers

There is an example in the docs specific to handling days of the week. Just a simple | sort -date_wday doesn't work since that will just sort alphabetically.

http://docs.splunk.com/Documentation/Splunk/5.0/SearchReference/sort

... | eval wd=lower(Day) | eval sort_field=case(wd=="monday",1, wd=="tuesday",2, wd=="wednesday",3, wd=="thursday",4, wd=="friday",5, wd=="weekend",6) | sort sort_field | fields - sort_field
0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...