Splunk Search

Problems with tonumber convertion - always returns the same value

ChrisLH
Explorer

Hi,

while doing some field comparisons I had problems matching one number field to another. After some research into my data I got the strange phenomena that converting my field to a number always leads to the same result.
My input value is already numerical but if a apply the following search:

sourcetype=systemevents eventTyp=PT0001 | eval number=tonumber(seriennummerZentral) | eval string=tostring(seriennummerZentral) | table seriennummerZentral number string

I get:

seriennummerZentral↕ number↕ string↕

06021001100101011000001492 6021001100101010952552448.000000 06021001100101011000001492
06021001100101011000001492 6021001100101010952552448.000000 06021001100101011000001492
06021001100101011000001492 6021001100101010952552448.000000 06021001100101011000001492
06021001100101011000001487 6021001100101010952552448.000000 06021001100101011000001487
06021001100101011000001487 6021001100101010952552448.000000 06021001100101011000001487
06021001100101011000001451 6021001100101010952552448.000000 06021001100101011000001451
06021001100101011000001487 6021001100101010952552448.000000 06021001100101011000001487
06021001100101011000001451 6021001100101010952552448.000000 06021001100101011000001451
06021001100101011000001487 6021001100101010952552448.000000 06021001100101011000001487
06021001100101011000001451 6021001100101010952552448.000000 06021001100101011000001451
06021001100101011000001487 6021001100101010952552448.000000 06021001100101011000001487
06021001100101011000001487 6021001100101010952552448.000000 06021001100101011000001487

seriennummerZentral is changing as is string but number is always the same

Tags (3)
0 Karma
1 Solution

somesoni2
Revered Legend

I guess that you've hit the limit of integers when converting to number. Do you have any specific need for the conversion?

View solution in original post

ChrisLH
Explorer

yeaa, you're probably right 🙂
and I think the problem was the integer limit.
Thx !

0 Karma

somesoni2
Revered Legend

I believe you won't be doing any numeric operation on the Serial No fields, you should use it as string (with conversion if required).

0 Karma

ChrisLH
Explorer

I wanted to select events by comparing two number fields:
seriennummerZentral seriennummerFzg
with the search statement:

sourcetype=systemevents eventTyp=PT0001 | where seriennummerZentral=seriennummerFzg

and got only positve results no matter the values. I figured it's maybe a problem with data types and tryed converting to number and to string.
| where tostring (seriennummerZentral) = tostring (seriennummerFzg)
is working
| where tonumber (seriennummerZentral) = tonumber (seriennummerFzg)
gives the same results as the initial statement, always true

0 Karma

somesoni2
Revered Legend

I guess that you've hit the limit of integers when converting to number. Do you have any specific need for the conversion?

martin_mueller
SplunkTrust
SplunkTrust

Being slightly pedantic here, but what's actually happening is that 6,021,001,100,101,010,952,552,448 is the most accurate IEEE754 Double representation - for all of your input serial numbers. The small differences between them are beyond what a Double can distinguish.

For comparison, the next bigger Double with no other values between them would be 6,021,001,100,101,012,026,294,272 - about a billion higher.

Get Updates on the Splunk Community!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...