Splunk Search

conditionally using random()

abby_xr
Splunk Employee
Splunk Employee

Based on my dataset, I have 10 items in total and I wanna generate a new field randomly for each different item. 

E.g.:

basesearch

| eval new_field=case(
FieldA=item_1,(random() % 4) + 1,
FieldA=item_2,(random() % 4) + 1,
FieldA=item_3, (random() % 4) + 1,
......
FieldA=item_10, (random() % 4) + 1)

but the results of new_field for each item are different. what I want is the newfield_1 is fixed, for example,

"newfield_1=(random() % 4) + 1, if fiedA==item_1: FieldA=newfield_1 (newfield_1 won't change again)"

How can I keep consistent for the different items? Thank you for the help.

Labels (2)
0 Karma
Get Updates on the Splunk Community!

Fun with Regular Expression - multiples of nine

Fun with Regular Expression - multiples of nineThis challenge was first posted on Slack #regex channel ...

[Live Demo] Watch SOC transformation in action with the reimagined Splunk Enterprise ...

Overwhelmed SOC? Splunk ES Has Your Back Tool sprawl, alert fatigue, and endless context switching are making ...

What’s New & Next in Splunk SOAR

Security teams today are dealing with more alerts, more tools, and more pressure than ever.  Join us on ...