Skip to content
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

out_gelf: accept possible level values #2257

Merged

Conversation

alitoufighi
Copy link
Contributor

@alitoufighi alitoufighi commented Jun 14, 2020

As discussed with myself in #2256, the restrictions on log level in GELF is a should, and also it is an optional field; so it doesn't seem to have a hard restriction on level value, as Graylog accepts the non-standard levels.
So I changed the attempt to be some kind of best-effort to match with standards, but if it's not, send it anyway and just throw a warning.

This PR also adds invocation of an error when level is not a string or a non-negative integer (As I haven't seen any negative log level and I think other data types mustn't be valid, yes?)


Testing

  • Example configuration file for the change
  • [N/A] Debug log output from testing the change
  • [N/A] Attached Valgrind output that shows no leaks or memory corruption was found

Documentation

  • [N/A] Documentation required for this feature

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.

Signed-off-by: Mohammad Ali Toufighi <[email protected]>
@alitoufighi
Copy link
Contributor Author

Using this config file:

[INPUT]
        Name   dummy
        Tag    kube.dummy
        Dummy {"level": -10, "time": "2020-06-13T15:02:12.637309", "host": "node1", "short_message":"{\"key1\":\"val1\"}"}

[OUTPUT]
        Name                    gelf
        Match                   *
        Host                    graylog-instance
        Port                    12201
        Mode                    tcp
        Gelf_Short_Message_Key  short_message

The output would include:

[error] [flb_msgpack_to_gelf] level must be a non-negative integer or a string

After changing level to 10:

[ warn] [flb_msgpack_to_gelf] level is 10, but should be in 0..7 or a syslog keyword

After changing to "ERROR":

[ warn] [flb_msgpack_to_gelf] level is 'ERROR', but should be in 0..7 or a syslog keyword

@edsiper edsiper merged commit 9cac770 into fluent:master Nov 27, 2020
@edsiper
Copy link
Member

edsiper commented Nov 27, 2020

thanks!

edsiper pushed a commit that referenced this pull request Dec 2, 2020
* change error logs to warning and remove abortion of sending logs when warning occurs
* error when level type is invalid

Signed-off-by: Mohammad Ali Toufighi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants