Splunk Search

Subtracting constant from field element-wise

light_of_sirius
Explorer

Hello,

i have a field and i want to generate a new field that is the old field but its mean subtracted.

Example:

[1,2,3] -> [-1, 0, 1]

 

This is my attempt

| makeresults count=10
| eval dice_toss = random()%6+1
| table dice_toss
| stats avg(dice_toss) as tmp
| eval dice_toss_centered = dice_toss - tmp

 

Labels (2)
0 Karma
1 Solution

renjith_nair
Legend

replace stats with eventstats

| makeresults count=10
| eval dice_toss = random()%6+1
| table dice_toss
| eventstats avg(dice_toss) as tmp|eval tmp=round(tmp,0)
| eval dice_toss_centered = dice_toss - tmp

 

Happy Splunking!

View solution in original post

renjith_nair
Legend

replace stats with eventstats

| makeresults count=10
| eval dice_toss = random()%6+1
| table dice_toss
| eventstats avg(dice_toss) as tmp|eval tmp=round(tmp,0)
| eval dice_toss_centered = dice_toss - tmp

 

Happy Splunking!
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, ...