Splunk Search

Group data 'n' rows at a time

nikita012
New Member

I have 40 rows in my data with fields Date, Total. I want to add the values of Total for each 5 days. How can I group data 5 rows at a time?

0 Karma
1 Solution

renjith_nair
Legend

@nikita012,

Try this,

"your current search"
|streamstats count as rowno|eval _fives=if((rowno-1)%5==0,1,0)
|accum _fives as group|eventstats sum(total) by group

you may replace eventstats with stats if you do not want other fields

Happy Splunking!

View solution in original post

renjith_nair
Legend

@nikita012,

Try this,

"your current search"
|streamstats count as rowno|eval _fives=if((rowno-1)%5==0,1,0)
|accum _fives as group|eventstats sum(total) by group

you may replace eventstats with stats if you do not want other fields

Happy Splunking!
Get Updates on the Splunk Community!

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, ...

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...