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

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

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!

Using Machine Learning for Hunting Security Threats

WATCH NOW Seeing the exponential hike in global cyber threat spectrum, organizations are now striving more for ...

Observability Newsletter Highlights | March 2023

 March 2023 | Check out the latest and greatestSplunk APM's New Tag Filter ExperienceSplunk APM has updated ...

Security Newsletter Updates | March 2023

 March 2023 | Check out the latest and greatestUnify Your Security Operations with Splunk Mission Control The ...