This is a really neat problem! Does doing something like this get you where you are trying to go? | makeresults
| fields - _time
| eval nums="1,2,3,4,5,6,7,8,9,10"
| makemv nums delim=","
| eval cnt=0
| foreach mode=multivalue nums
[
| eval
moving_window_size=3,
summation_json=if(
mvcount(mvindex(nums,cnt,cnt+('moving_window_size'-1)))=='moving_window_size',
mvappend(
'summation_json',
json_object(
"set", mvindex('nums', 'cnt', 'cnt'+('moving_window_size'-1)),
"sum", sum(mvindex('nums', 'cnt', 'cnt'+('moving_window_size'-1)))
)
),
'summation_json'
),
cnt='cnt'+1
] End result looks something like this: I'm sure this can be standardized more and not sure how you want the final results to be formatted but you should be able to parse out the final MV json objects to get what you need out of them. Update: With the addition of the field "moving_window_size" it is a bit more standardized. And here it is in a slightly different format (summations associated with their own fields): | makeresults
| fields - _time
| eval nums="1,2,3,4,5,6,7,8,9,10"
| makemv nums delim=","
| eval cnt=0
| foreach mode=multivalue nums
[
| eval
moving_window_size=3,
iter_count="iteration_".'cnt',
summation_json=if(
mvcount(mvindex('nums', 'cnt', 'cnt'+('moving_window_size'-1)))=='moving_window_size',
if(
isnull(summation_json),
json_object('iter_count', sum(mvindex('nums', 'cnt', 'cnt'+('moving_window_size'-1)))),
json_set(summation_json, 'iter_count', sum(mvindex('nums', 'cnt', 'cnt'+('moving_window_size'-1))))
),
'summation_json'
),
cnt='cnt'+1
]
| fromjson summation_json
| fields - summation_json, iter_count, cnt
| fields + nums, iteration_* And this SPL to try and simulate your original use-case (also added some addition context in the output): | makeresults count=1500
| eval
low=1,
high=100,
rand=round(((random()%'high')/'high')*('high'-'low')+'low')
| stats
list(rand) as nums
| eval cnt=0
| foreach mode=multivalue nums
[
| eval
moving_window_size=5,
summation_json=if(
mvcount(mvindex(nums,cnt,cnt+('moving_window_size'-1)))=='moving_window_size',
mvappend(
'summation_json',
json_object(
"set", mvindex('nums', 'cnt', 'cnt'+('moving_window_size'-1)),
"sum", sum(mvindex('nums', 'cnt', 'cnt'+('moving_window_size'-1))),
"average", sum(mvindex('nums', 'cnt', 'cnt'+('moving_window_size'-1)))/'moving_window_size',
"min", min(mvindex('nums', 'cnt', 'cnt'+('moving_window_size'-1))),
"max", max(mvindex('nums', 'cnt', 'cnt'+('moving_window_size'-1)))
)
),
'summation_json'
),
cnt='cnt'+1
]
| eval
average_sum=sum(mvmap(summation_json, tonumber(spath(summation_json, "sum"))))/mvcount(summation_json),
min_sum=min(mvmap(summation_json, tonumber(spath(summation_json, "sum")))),
max_sum=max(mvmap(summation_json, tonumber(spath(summation_json, "sum")))) You can see by the screenshot below that I hit some Splunk limits when trying to put together a MV field with 1,500 entries (truncates to 250). But other than that it seems to work.
... View more