Splunk Search

How do I stop Splunk from rounding values that are less than 1?

jambalaya_rice
Engager

I was doing basic operations (+ - * / ) in Splunk and I noticed that if I was subtracting a number less than 0 with another number that is basically 0 (i.e. 0.04190232 - 0.0), it would return 0 unless I put the expression in an eval function called exact.

How can I make Splunk NEVER round in my search?

Tags (3)
0 Karma

somesoni2
Revered Legend

When performing mathematical operations between two decimal operands, the Splunk takes the lowest precision of the two operands and use the same in final result. So,

0.04190232 - 0.0 = 0  [ same as round(0.04190232,1) ]
0.04190232 - 0.00 = 0.04  [ same as round(0.04190232,2) ]
0.04190232 - 0.000 = 0.042  [ same as round(0.04190232,3) ]

If one of the operand is integer, then a lowest precision of remaining decimal operand is considered for final result

 0.04190232 - 0 = 0.04190232  [ takes precision of 0.04190232 ]
 0.04190232 - 0.00 - 0 = 0.04  [ takes precision of 0.00 ]

So, choose/define appropriate precision for your operands.

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