I am running graylog 3.1 on centos 7.7 with elasticsearch 6.8. I am having an issue where graylog is rejecting messages with this error:
2020-06-16T11:36:02.881Z WARN [Messages] Failed to index message: index=<grayloglod_20> id= error=<{“type”:“mapper_parsing_exception”,“reason”:“failed to parse field [level] of type [long] in document with id ‘id’”,“caused_by”:{“type”:“illegal_argument_exception”,“reason”:“For input string: “INFO””}}>
I do not have any configuration that specifies the “level” field must be an int.
I have other graylog instances on same versions where this does not occur, and on those installs the “level” field is successfully translated from INFO to 6. I do not have an elasticsearch template or a graylog pipeline to do this, so i am unsure where it happens.
graylog uses elastic dynamic mapping to define schema, so if your first message field level is numeric (float) it will create field with this type. Another message with message field level with string will fail, because of another type. Best way is to create separate index for different source messages and don’t mix them all…
Sorry to pester you, but in the event that all logs are coming in through the same input, is there any way I could add a pipeline that would rewrite any non integer level fields?
Something like:
rule “level to long”
when
has_field(“level”) && $message.level == “info”
then
remove_field(“level”);
set_field(“level”, 6);
end
Thanks again shoothub, it does indeed appear to be working.
For posterity:
rule “info level to int”
when
has_field(“level”) && lowercase(to_string($message.level)) == “info”
then
remove_field(“level”);
set_field(“level”, 6);
end
rule “warn level to int”
when
has_field(“level”) && lowercase(to_string($message.level)) == “warn”
then
remove_field(“level”);
set_field(“level”, 4);
end
I added these to a pipeline connected to all messages.