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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Splunk App Dev Quarterly Roundup: AI, Agents, and Innovation!

Another quarter, another wave of innovation. From complex integrations to pushing the limits ...

Federated Search for Dynamic Data Self Storage Is Now Generally Available on Splunk ...

 Splunk is excited to announce the General Availability of Federated Search for Dynamic Data Self Storage ...

Index This | What has many keys but can’t unlock a door?

July 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...