Splunk Search

How to calculate (total or YTD/year-to-date) accumulated count based on region (or other group)

kalitbri
Explorer

How to calculate (total or YTD/year-to-date) accumulated count based on region (or other group) in a search request? Like the last 2 field in following example data:

http://paste.plurk.com/show/268913/

Tags (1)
0 Karma
1 Solution

gkanapathy
Splunk Employee
Splunk Employee

the streamstats command:

... | bucket _time span=1mon | stats count by _time,region | streamstats global=f current=t sum(count) as cum_count by _time,region

I don't know how to do YTD.

View solution in original post

0 Karma

gkanapathy
Splunk Employee
Splunk Employee

the streamstats command:

... | bucket _time span=1mon | stats count by _time,region | streamstats global=f current=t sum(count) as cum_count by _time,region

I don't know how to do YTD.

0 Karma

kalitbri
Explorer

I tested but only works after i removed _time from by-clause in streamstats. Thanks anyway! I can achieve YTD similarly, by:

... | eval _year=_time | bucket _time span=1mon | bucket _year span=1year | stats count by _time,region | streamstats global=f current=t sum(count) as ytd_count by region,_year | fields _time,region,ytd_count

0 Karma

kalitbri
Explorer

Thanks! how about similar way , but by _time@Y for YTD?

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...