Open jonaslb opened 9 months ago
Using this setup I actually also can't get b64-encoded data to work right. We do have some base64-encoded data working when running from kafka though, but I initially ran into this issue when attempting to move away from base64-encoding (ie also over kafka).
Updated because I found a Kafka option that makes it work. The new description asks to make this requirement clear in the documentation.
New description
I was not able to get the codec to work based on a Kafka input, and I created a minimum example using the file input plugin in the original description.
I did then discover the
value_deserializer_class => "org.apache.kafka.common.serialization.ByteArrayDeserializer"
option for the Kafka plugin, which I think is probably a reasonable thing to require, however it was unclear to me that this was required.Indeed the documentation for this plugin makes no mention of this special requirement for input plugins. I think that should probably be added to the main description and the description for the binary encoding option.
Plugins which do not have an option similar to the one for the Kafka plugin would then be completely unsupported and that should probably also be mentioned.
Old description
Logstash information:
Logstash version 8.12.1, running the official docker image via docker cli.
Description of the problem including expected versus actual behavior:
Deserialization of avro records does not work using the binary (plain) encoding.
It looks like this was well-known back when it was decided that Logstash should only work with base64 encoded data, however we had an expectation from the documentation and the recent addition of the binary encoding that it would also work with plain data.
If the problem is unfixable, then at the very least the documentation should be updated to say in quite large letters that for decoding, still only base64 is supported.
Steps to reproduce:
example-schema.avsc
below):schema = avro.schema.parse(open("example-schema.avsc").read()) writer = DatumWriter(schema) with open("example_record.avro", "wb") as f: encoder = BinaryEncoder(f) data = {"f1": "x" * 192} writer.write(data, encoder) f.write(b"\n")
input { file { path => ["/usr/share/logstash/example_record.avro"] codec => avro { schema_uri => "/usr/share/logstash/example-schema.avsc" encoding => binary } exit_after_read => true mode => read } } filter { ruby { code => 'logger.error("test")' } } output { stdout {} }
Provide logs (if relevant):
The following error is output: