Splunk Search

How to get cumulative numbers

xvxt006
Contributor

Hi,

I am getting number of orders per hour and last week same hour orders and delta percentage. i run this every hour (using basic schedule) to get previous hour orders in an email. Now i want to get cumulative totals. How can we accomplish this in a scheduled search.

For example hour1 have below numbers and hour2, it should be total of hour1+hour2. Hour3 it should be Hour1+Hour2+Hour3.

Measure Value
OrdersLastHour 1181
OrdersLastWeekSameHour 734
OrderDeltaPct 60.90

Tags (1)
0 Karma
1 Solution

jbrodsky_splunk
Splunk Employee
Splunk Employee

Try using accum.

... | bucket _time span=1h | stats count by _time |accum count as total_count

View solution in original post

0 Karma

jbrodsky_splunk
Splunk Employee
Splunk Employee

Try using accum.

... | bucket _time span=1h | stats count by _time |accum count as total_count
0 Karma

jbrodsky_splunk
Splunk Employee
Splunk Employee

Try:

earliest=-week-1h latest=-week

Then run it every hour...

0 Karma

xvxt006
Contributor

Thank you. one question is, as i want to compare today vs last week by hour, how can i specify time so that every hour when i run the scheduled search it runs for this hour last week. Meaning if it is 1 pm today, it will get the numbers till 1 pm today and last week same day it should run till 1 pm. After another hour it should run till 2 pm, etc. is it possible to specify the time interval in such a way?

0 Karma

jbrodsky_splunk
Splunk Employee
Splunk Employee

There's no time range specified in my search - it will work against whatever time range you specify. If you want to do last full week, prepend it with:

earliest=-7d@w0 latest=@w7

0 Karma

xvxt006
Contributor

Thank you. I will try. Does this work even for numbers for same time last week?

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!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...