Skip to content

out_gelf: fix not escaping quotes in strings inside arrays, producing invalid JSON #10574

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ulexxander
Copy link

@ulexxander ulexxander commented Jul 10, 2025

Fixes #9638

For GELF output fixes escaping of string contents inside arrays (See the issue)

Before:

{
  "version": "1.1",
  "_log": "info",
  "_time": "2025-01-07T08:44:05+00:00",
  "short_message": "Example message",
  "_some_list": "{"project":"FluentBit","description":"Great"}, {"project":"Grafana","description":"Great too"}",
  "timestamp": 1736252577.548
}

After:

{
    "version": "1.1",
    "_log": "info",
    "_time": "2025-01-07T08:44:05+00:00",
    "short_message": "Example message",
    "_some_list": "{\"project\":\"FluentBit\",\"description\":\"Great\"}, {\"project\":\"Grafana\",\"description\":\"Great too\"}",
    "timestamp": 1752144635.149
}

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
services:
  fluent-bit:
    image: fluent/fluent-bit:3.2.4
    volumes:
      - ./fluent-bit.conf:/fluent-bit/etc/fluent-bit.conf

fluent-bit.conf

[SERVICE]
    Flush         1
    Daemon        Off
    Log_Level     info
    Parsers_File  parsers.conf
    Plugins_File  plugins.conf
    HTTP_Server   On
    HTTP_Listen   0.0.0.0
    HTTP_Port     2020

[INPUT]
    Name      dummy
    Dummy     {"log":"info","time":"2025-01-07T08:44:05+00:00","description":"Example message","some_list":["{\"project\":\"FluentBit\",\"description\":\"Great\"}","{\"project\":\"Grafana\",\"description\":\"Great too\"}"]}

[OUTPUT]
    Name                    gelf
    Match                   *
    Host                    example.com
    Port                    12201
    Mode                    tcp
    Gelf_Short_Message_Key  description
  • Debug log output from testing the change

Dump contents sent on GELF TCP port:

nc -lk -p 12201

Then run fluent-bit and check output of nc:

{"version":"1.1", "_log":"info", "_time":"2025-01-07T08:44:05+00:00", "short_message":"Example message", "_some_list":"{\"project\":\"FluentBit\",\"description\":\"Great\"}, {\"project\":\"Grafana\",\"description\":\"Great too\"}", "timestamp":1752144633.149}

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • [N/A] Run local packaging test showing all targets (including any new ones) build.
  • [N/A] Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • [N/A]

Backporting

  • [N/A] Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect Backslash Escaping in Array Elements in GELF Output
1 participant