我们有以下设置:
-
logstash版本5.5
-
logstash avro编解码器版本3.2.1
-
卡夫卡版本0.10.1
-
例如,考虑以下模式:
{
"name" : "avroTestSchema",
"type" : "record",
"fields" : [ {
"name" : "testfield1",
"type" : "string"
},
{
"name" : "testfield2",
"type" : "string"
}
]
}
和以下json字符串:
{"testfield1":"somestring","testfield2":"anotherstring"}
使用Logstash序列化时。
input {
stdin {
codec => json
}
}
filter {
mutate {
remove_field => ["@timestamp", "@version"]
}
}
output {
kafka {
bootstrap_servers => "localhost:9092"
codec => avro {
schema_uri => "/path/to/TestSchema.avsc"
}
topic_id => "avrotestout"
}
stdout {
codec => rubydebug
}
}
FHNvbWVzdHJpbmcaYW5vdGhlcnN0cmluZw==
java -jar avro-tools-1.8.2.jar jsontofrag --schema-file TestSchema.avsc message.json
输出
somestringanotherstring
java -jar avro-tools-1.8.2.jar fromjson --schema-file TestSchema.avsc message.json
Objavro.codenullavro.schemaâ{"type":"record","name":"avroTestSchema","fields":[{"name":"testfield1","type":"string"},{"name":"testfield2","type":"string"}]}ââââ&70ââHsâU2somestringanotherstringââââ&70ââHsâU
所以我们的问题是:
更新:我们发现logstash生成的avro输出是base64编码的。但是,无法找到发生这种情况的地方,以及如何使其与avro工具兼容