Splunk Search

Count By Date

gn694
Communicator

I have a search created, and want to get a count of the events returned by date. I know the date and time is stored in time, but I dont want to Count By _time, because I only care about the date, not the time. Is there a way to get the date out of _time (I tried to build a rex, but it didnt work..)
I also tried to do a count based on date_mday, but when adding that I got no results returned (nor did I get any results when I just added something like date_mday > 1 to the search string) - seems like the date
fields are not populated for me (in this case, these are events from the Windows System log.)

Any suggestions on how to count by date?

thankx.

Tags (3)
1 Solution

yannK
Splunk Employee
Splunk Employee

Convert _time to a date in the needed format.

* | convert timeformat="%Y-%m-%d" ctime(_time) AS date | stats count by date

see http://docs.splunk.com/Documentation/Splunk/5.0.3/SearchReference/Convert

View solution in original post

idaaa
Explorer
  • | eval date=strftime(_time, "%y-%m-%d") | stats count by date

yannK
Splunk Employee
Splunk Employee

Convert _time to a date in the needed format.

* | convert timeformat="%Y-%m-%d" ctime(_time) AS date | stats count by date

see http://docs.splunk.com/Documentation/Splunk/5.0.3/SearchReference/Convert

dkhiggs
Engager

"%F" is equivalent to "%Y-%m-%d"

0 Karma

gn694
Communicator

Thank you!!!

0 Karma

hoanlq
Engager

Thanks a lot

0 Karma
Get Updates on the Splunk Community!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...