Splunk Search

How to group events by date?

thl8490123
New Member

Hi, 

I manage to get the view i want using below search command.  

May I know how to group the events by Month_Year format and display on the table besides the events? 

Current View

Splunk Search.png

Expected

Splunk Search.png

 

Labels (1)
0 Karma

niketn
Legend

@thl8490123 based on the screenshot and SPL provided in the question, you are better off running tstats query which will perform way better.

Please try out the following SPL and confirm

| tstats count where index=main source IN ("wineventlog:application","wineventlog:System","wineventlog:security") by host _time source span=1mon
| eval {source}=count
| fields - source count

 

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

to4kawa
Ultra Champion

I tried to follow the image.

| tstats count where index=main source IN ("wineventlog:application","wineventlog:System","wineventlog:security") by host _time source span=1mon 
| eval time=strftime(_time,"%b %Y") , hosts=host."::".time 
| fields - host _time 
| xyseries hosts source count 
| rex field=hosts "(?<host>.*)::(?<month>.*)" 
| table host month win* 
| addcoltotals 
| appendpipe 
    [ tail 1 
    | addtotals 
    | eval wineventlog:application = round('wineventlog:application' / Total * 100,2)
    | eval wineventlog:security = round('wineventlog:security' / Total * 100,2)
    | eval wineventlog:system = round('wineventlog:system' / Total * 100,2)
    | fields - Total]

I am not able to use foreach in subsearch. 

| foreach win* [ eval <<FIELD>> = round(<<FIELD>> / Total * 100, 2) ]

I'm disappointment.

 

0 Karma

niketn
Legend

@to4kawa The sum total and percent in the screenshot is from the built in formatting option for the Table. So SPL is not really needed!

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

to4kawa
Ultra Champion

I've never heard of it before. 😅

0 Karma
Get Updates on the Splunk Community!

Data Management Digest – November 2025

  Welcome to the inaugural edition of Data Management Digest! As your trusted partner in data innovation, the ...

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...