Splunk Search

How to summarize a lot of fields with mvappend

takeru
New Member

I am trying to find the standard deviation from the postfix log.
I assume the following search sentence.

index=postfix earliest=-50d
| timechart span=1d count by fromaddress
| eval readable_time=strftime(_time, "%Y-%m-%d ")
| fields - NULL OTHER _time _span _spandays
| transpose 50
| rename "row " as day
| eval mvfield=mvappend(day1,day2,day3,day4,day5............)
| stats avg(mvfield) as avg stdev(mvfield) as std by column

Is there a way to more easily define day 1 to day 50?
| eval mvfield=mvappend(day1,day2,day3,day4,day5............)

0 Karma
1 Solution

somesoni2
Revered Legend

Give this a try

index=postfix earliest=-50d
| timechart span=1d count by fromaddress
| eval readable_time=strftime(_time, "%Y-%m-%d ")
| fields - NULL OTHER _time _span _spandays
| transpose 50
| rename "row " as day
| eval mvfield=null() | foreach day* [eval mvfield=mvappend(mvfield,'<<FIELD>>')]
| stats avg(mvfield) as avg stdev(mvfield) as std by column

View solution in original post

0 Karma

somesoni2
Revered Legend

Give this a try

index=postfix earliest=-50d
| timechart span=1d count by fromaddress
| eval readable_time=strftime(_time, "%Y-%m-%d ")
| fields - NULL OTHER _time _span _spandays
| transpose 50
| rename "row " as day
| eval mvfield=null() | foreach day* [eval mvfield=mvappend(mvfield,'<<FIELD>>')]
| stats avg(mvfield) as avg stdev(mvfield) as std by column
0 Karma

somesoni2
Revered Legend

Also, try this

index=postfix earliest=-50d
 | timechart span=1d count by fromaddress
 | eval readable_time=strftime(_time, "%Y-%m-%d ")
 | fields - NULL OTHER _time _span _spandays
| untable readable_time column valuefield
| stats avg(valuefield) stdev(valuefield) by column
0 Karma

takeru
New Member

The answer I was hoping for
Thank you!

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...