Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

GELF message seems to be missing mandatory field "version" #259

Closed
mikknormak opened this issue Feb 4, 2021 · 2 comments · Fixed by #260
Closed

GELF message seems to be missing mandatory field "version" #259

mikknormak opened this issue Feb 4, 2021 · 2 comments · Fixed by #260
Labels
type: bug A general bug
Milestone

Comments

@mikknormak
Copy link

GELF message format:
https://docs.graylog.org/en/latest/pages/gelf.html
defines:

version string (UTF-8)
GELF spec version – “1.1”; MUST be set by client library.

https://github.com/mp911de/logstash-gelf/blob/main/src/main/java/biz/paluch/logging/gelf/intern/GelfMessage.java
des use

GELF_VERSION_1_1.equals(version)

to define version specific "timestamp" and "level" formats, but does not seem to include a "version" field into final JSON message.
(and since all custom field are prefixed with "_" there is also no (easy) way to manually provide "version" field)

perhaps something like this:

public static final String FIELD_VERSION = "version";
...
if (GELF_VERSION_1_1.equals(version)) {
hasFields = writeIfNotEmpty(out, hasFields, FIELD_VERSION, GELF_VERSION_1_1);
}

or perhaps more future-proof:

public static final String FIELD_VERSION = "version";
...
if (!isEmpty(version) && !GELF_VERSION_1_0.equals(version)) {
hasFields = writeIfNotEmpty(out, hasFields, FIELD_VERSION, version);
}

in case GELF_VERSION_1_0 must not include the "version" field

@mp911de
Copy link
Owner

mp911de commented Feb 4, 2021

Good catch. I think the second variant makes sense. Do you want to submit a pull request?

@mp911de mp911de added the type: bug A general bug label Feb 4, 2021
@mikknormak
Copy link
Author

Sure:
#260

@mp911de mp911de linked a pull request Mar 1, 2021 that will close this issue
@mp911de mp911de added this to the 1.15.0 milestone Mar 1, 2021
@mp911de mp911de closed this as completed Mar 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants