Splunk Search

Timechart count of -30d rolling window

hoiby
Explorer

I'm looking to create a timechart of counts for a field where there is one bucket per day, and each bucket spans back 30 days. So the search would return a count for -30d to now, and -31d to -1d, and -32d to -2d, and so on, ideally back to the oldest index entry. I intend to display the counts directly on a line chart and also do some basic evals on the counts (like percentages). The idea is to get a historical snapshot of data from the perspective of each day. I've read some other posts that point to summary indexing as an answer, and that seems like it would solve the problem for future data, but I also have a need to look at historical data right now rather than wait for the summary index to be built to be able to see a trend.

0 Karma
1 Solution

sc0tt
Builder

I believe creating a summary index is the best solution for this scenario. You can backfill the index so that you can use historical data. Somebody may be able to provide a better solution, but this is the method that I've used for similar types of reports.

View solution in original post

sc0tt
Builder

I believe creating a summary index is the best solution for this scenario. You can backfill the index so that you can use historical data. Somebody may be able to provide a better solution, but this is the method that I've used for similar types of reports.

hoiby
Explorer

Thanks for the quick responses. I was able to get the appropriate results using streamstats as you suggested, but without building a summary index. In this scenario, would the purpose of the index be just for performance reasons? Does the data in the summary index persist for a longer time than our (90 day) normal index so we could search the summary of todays data in say, 1 year?

0 Karma

somesoni2
Revered Legend

Agree with sc0tt, it seems you want to show timechart for all data in your index which should be expensive. Have a summary index configured to save data on daily basis (for historical data as well) and then use streamstats to get the rolling count, something like below-

your base search | timechart span=1d count(yourfield) as yourfield | streamstats sum(yourfield) as Count window=30

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