# ArgumentError when using Kafka input Avro codec

**URL:** <https://discuss.elastic.co/t/argumenterror-when-using-kafka-input-avro-codec/116975>\
**Category:** Logstash\
**Created:** [January 25, 2018, 6:31am UTC](https://discuss.elastic.co/t/argumenterror-when-using-kafka-input-avro-codec/116975 "2018-01-25T06:31:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![elasticheart](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticheart/32/65189_2.png) [@elasticheart](https://discuss.elastic.co/u/elasticheart)\
**Post date:** [January 25, 2018, 6:31am UTC](https://discuss.elastic.co/t/argumenterror-when-using-kafka-input-avro-codec/116975/1 "2018-01-25T06:31:08Z")

</div>

Hi everyone,

I am using ELK GA 6.0.0. I have avro records in my Kafka topic and I am trying to push them into elasticsearch using Logstash Kafka input plugin using [Avro Codec](https://www.elastic.co/guide/en/logstash/6.0/plugins-codecs-avro.html). Below is my configuration, its pretty simple and minimal;

```
input {
	kafka{
		group_id => "group_1"
		topics => ["topic_1"]
		bootstrap_servers => "192.168.0.1:9092"
		codec => avro {
			schema_uri => "/files/GA6/logstash-6.0.0/CONFIG_HOME/myschema.avsc"
		}
	}
}

output{
	stdout{

	}
}

```

What I am getting is the below error, when I am trying to start Logstash (manual line break applied);

```
[2018-01-25T11:54:37,060][FATAL][logstash.runner] An unexpected error occurred! 
{:error=>#<ArgumentError: negative length -15 given>, :backtrace=>[
"org/jruby/ext/stringio/StringIO.java:788:in `read'", 
"/files/GA6/logstash-6.0.0/vendor/bundle/jruby/2.3.0/gems/avro-1.8.2/lib/avro/io.rb:106:in `read'", 
"/files/GA6/logstash-6.0.0/vendor/bundle/jruby/2.3.0/gems/avro-1.8.2/lib/avro/io.rb:93:in `read_bytes'", 
"/files/GA6/logstash-6.0.0/vendor/bundle/jruby/2.3.0/gems/avro-1.8.2/lib/avro/io.rb:99:in `read_string'", 
"/files/GA6/logstash-6.0.0/vendor/bundle/jruby/2.3.0/gems/avro-1.8.2/lib/avro/io.rb:299:in `read_data'", 
"/files/GA6/logstash-6.0.0/vendor/bundle/jruby/2.3.0/gems/avro-1.8.2/lib/avro/io.rb:384:in `block in read_record'", 
"org/jruby/RubyArray.java:1734:in `each'", 
"/files/GA6/logstash-6.0.0/vendor/bundle/jruby/2.3.0/gems/avro-1.8.2/lib/avro/io.rb:382:in `read_record'", 
"/files/GA6/logstash-6.0.0/vendor/bundle/jruby/2.3.0/gems/avro-1.8.2/lib/avro/io.rb:310:in `read_data'", 
"/files/GA6/logstash-6.0.0/vendor/bundle/jruby/2.3.0/gems/avro-1.8.2/lib/avro/io.rb:275:in `read'", 
"/files/GA6/logstash-6.0.0/vendor/bundle/jruby/2.3.0/gems/logstash-codec-avro-3.2.3-java/lib/logstash/codecs/avro.rb:77:in `decode'", 
"/files/GA6/logstash-6.0.0/vendor/bundle/jruby/2.3.0/gems/logstash-input-kafka-8.0.2/lib/logstash/inputs/kafka.rb:254:in `block in thread_runner'", 
"/files/GA6/logstash-6.0.0/vendor/bundle/jruby/2.3.0/gems/logstash-input-kafka-8.0.2/lib/logstash/inputs/kafka.rb:253:in `block in thread_runner'"
]}

```

Below is my avsc;

```
{
	"type": "record",
	"name": "Sample",
	"doc": "Sample Schema",
	"fields": [{
			"name": "name",
			"type": "string"
		}, {
			"name": "address",
			"type": "string"
		}, {
			"name": "salary",
			"type": "long"
		}
	]
}

```

I have referred [this question](https://discuss.elastic.co/t/logstash-5-2-not-working-with-kafka-9-and-avro/73810) and added the below config to my input;

```
key_deserializer_class => "org.apache.kafka.common.serialization.ByteArrayDeserializer"
value_deserializer_class => "org.apache.kafka.common.serialization.ByteArrayDeserializer"

```

Still, the issues persists. Why is this happening? How can I fix this?

Thank you.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 22, 2018, 6:31am UTC](https://discuss.elastic.co/t/argumenterror-when-using-kafka-input-avro-codec/116975/2 "2018-02-22T06:31:09Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
