-
Notifications
You must be signed in to change notification settings - Fork 18
Description
(This issue was originally filed by @nvx at elastic/logstash#1636)
I have a simple logstash configuration that reads snmptraps and outputs them to redis which is json encoded.
Some messages fail to make it to redis with the logstash log reporting "Failed to convert event to JSON. Invalid UTF-8, maybe?". Looking at the code this appears to originate from within the redis output.
input {
snmptrap {
type => "snmptrap"
codec => plain {
charset => "BINARY"
}
}
}
output {
redis {
host => "127.0.0.1"
data_type => "list"
key => "logstash-raw"
}
}
I have tried without specifying a codec, as well as explicitly setting the charset to BINARY. The SNMP traps do contain some non-ASCII characters (binary representations of MAC addresses and IP addresses) but they appear to be properly escaped with \xHH style notation in the output log.
The only difference I can spot between messages that make it to redis, compared ones that fail is the MAC address field. An example of a failing message has this field in the message part (Note it appears to be doubly escaped as this is from the error log which itself appears to be json encoded as well):
@value=\"\\xFC\\xF8\\xAE<.\\x18\"
And the same value again as parsed by the MIBs:
"MERU-WLAN-MIB::mwlApMacAddr" = > "\xFC\xF8\xAE<.\x18",
Other MAC addresses that start with FC:F8:AE work, so I can only assume it is the latter half (3C:2E:18) that is breaking the encoding.