-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filebeat unmarshals JSON integers as float64 #2038
Comments
equals
condition does not work on floats
The fact that JSON unmarshals all numbers to float is quite unfortunate. Maybe we can fix that.. |
This is the expected behavior. "equals" excepts only integers and strings as it doesn't really make sense for floats. If you want to compare a float, then the "range" operation is needed. |
@andrewkroh How the numbers look like in the json file? Do they look like integers? |
@monicasarbu Yes, the value is an integer in the JSON. I included an example in the description. I updated the title to reflect the fact that the focus should probably be on the unmarshaling behavior instead of the processor condition since |
Unfortunately that's just how Unmarshal works in Go: if it's a number, put it in @andrewkroh @monicasarbu Thoughts? Alternatives? |
The change modifies the unmarshaling logic to try parsing the numbers in an int64 first, and only on error parse to a float64. In practice, this means that e.g. 1 will become an int64 and 1.0 will become a float64. Fixes elastic#2038. Includes a system test to verify that ticket.
The change modifies the unmarshaling logic to try parsing the numbers in an int64 first, and only on error parse to a float64. In practice, this means that e.g. 1 will become an int64 and 1.0 will become a float64. Fixes #2038. Includes a system test to verify that ticket.
Filebeat can unmarshal arbitrary JSON data, and when it unmarshals numbers they are of type float64. If you try to use a conditional filter with
equals
to match against a number read from JSON you get the following error.condition.go:240: WARN unexpected type float64 in equals condition as it accepts only integers and strings.
Filebeat version: 5.0.0 git c54b7c4
Config:
Input file:
The text was updated successfully, but these errors were encountered: