Skip to content

Float numbers in JSON stdout and http output plugin misformatted #6447

Description

@jennuineness

Bug Report

Describe the bug
Hi, I noticed certain float numbers such as 0.072 in a JSON data structure is being rewritten as 0.07199999999999999 when using the Format json option for the stdout and http output plugin.

I am sending out logs to a service that only accepts numbers with Decimal positions to be less than 16 digits. I am unable to find a way to preserve the number as-is when using the Format json option through the output plugins.

Any help with a fix/workaround is much appreciated!

To Reproduce

  • Rubular link if applicable:
  • Example log message if applicable:
{"test": 0.072}
  • Steps to reproduce the problem:

tail.conf

[SERVICE]
    Parsers_File parsers.conf
    Flush 0.1

[INPUT]
    Name            tail
    Path              /test.log
    Parser json

[OUTPUT]
    Name stdout
    Match *
    Format json
    json_date_key false

parsers.conf

[PARSER]
    Name   json
    Format json

test.log

{"test": 0.072}
  1. Setup environment with files listed above.
  2. Run following command in terminal where tail.conf is located: fluent-bit -c tail.conf
  3. Run the following command in a new terminal where test.log is located: echo '{"test": 0.072}' >> test.log

Expected behavior
Expect output to be [{"test":0.072}] instead of [{"test":0.07199999999999999}].

Your Environment

  • Version used: Fluent Bit v2.0.4
  • Configuration:
  • Environment name and version (e.g. Kubernetes? What version?):
  • Server type and version:
  • Operating System and version: MacOS Monterey v12.6
  • Filters and plugins: tail Input plugin, JSON parser plugin, stdout Output plugin, and HTTP Output plugin

Additional context

Possibly, allow an option to preserve the number types without being reformatted when parsing.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions