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
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

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