# How to Handle Exceptions?

**URL:** <https://discuss.elastic.co/t/how-to-handle-exceptions/194900>\
**Category:** Logstash\
**Created:** [August 12, 2019, 6:29pm UTC](https://discuss.elastic.co/t/how-to-handle-exceptions/194900 "2019-08-12T18:29:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cd-agutierrez](https://avatars.discourse-cdn.com/v4/letter/c/e79b87/32.png) [@cd-agutierrez](https://discuss.elastic.co/u/cd-agutierrez)\
**Post date:** [August 12, 2019, 6:29pm UTC](https://discuss.elastic.co/t/how-to-handle-exceptions/194900/1 "2019-08-12T18:29:22Z")

</div>

It seems that if logstash encounters an exception in the elasticsearch output pipeline it will completely halt processing of any further entries.

```
[2019-08-08T22:14:44,075][WARN][io.netty.channel.DefaultChannelPipeline] An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
java.lang.ClassCastException: java.util.HashMap cannot be cast to java.lang.String
        at org.logstash.Event.existingTag(Event.java:398) ~[logstash-core.jar:?]
        at org.logstash.Event.tag(Event.java:374) ~[logstash-core.jar:?]
        at org.logstash.ext.JrubyEventExtLibrary$RubyEvent.ruby_tag(JrubyEventExtLibrary.java:257) ~[logstash-core.jar:?]
        at usr.share.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.logstash_minus_input_minus_beats_minus_5_dot_1_dot_8_minus_java.lib.logstash.inputs.beats.raw_event_transform.RUBY$method$transform$0(/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstas
h-input-beats-5.1.8-java/lib/logstash/inputs/beats/raw_event_transform.rb:14) ~[?:?]
        at usr.share.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.logstash_minus_input_minus_beats_minus_5_dot_1_dot_8_minus_java.lib.logstash.inputs.beats.message_listener.RUBY$method$onNewMessage$0(/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstas
h-input-beats-5.1.8-java/lib/logstash/inputs/beats/message_listener.rb:41) ~[?:?]
        at usr.share.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.logstash_minus_input_minus_beats_minus_5_dot_1_dot_8_minus_java.lib.logstash.inputs.beats.message_listener.RUBY$method$onNewMessage$0$ __VARARGS__ (/usr/share/logstash/vendor/bundle/jruby/2.5.0/
gems/logstash-input-beats-5.1.8-java/lib/logstash/inputs/beats/message_listener.rb) ~[?:?]
        at org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:91) ~[jruby-complete-9.2.6.0.jar:?]
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:90) ~[jruby-complete-9.2.6.0.jar:?]
        at LogStash$$Inputs$$Beats$$MessageListener_1219897284.onNewMessage(LogStash$$Inputs$$Beats$$MessageListener_1219897284.gen:13) ~[?:?]
        at org.logstash.beats.BeatsHandler.channelRead0(BeatsHandler.java:52) ~[logstash-input-beats-5.1.8.jar:?]
        at org.logstash.beats.BeatsHandler.channelRead0(BeatsHandler.java:12) ~[logstash-input-beats-5.1.8.jar:?]
        at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) ~[netty-all-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) ~[netty-all-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) ~[netty-all-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) ~[netty-all-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323) ~[netty-all-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:297) ~[netty-all-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) ~[netty-all-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:38) ~[netty-all-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:353) ~[netty-all-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.util.concurrent.DefaultEventExecutor.run(DefaultEventExecutor.java:66) ~[netty-all-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897) [netty-all-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-all-4.1.30.Final.jar:4.1.30.Final]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_201]

```

I've tried looking up documentation on logstash configuration files to see if there is any way to handle this scenario, but I have found nothing.

So I ask here: how are you supposed to configure logstash to handle exceptions, or are logstash configuration files not the place to do it?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [August 12, 2019, 6:52pm UTC](https://discuss.elastic.co/t/how-to-handle-exceptions/194900/2 "2019-08-12T18:52:18Z")

</div>

> [@cd-agutierrez](#):
>
> how are you supposed to configure logstash to handle exceptions, or are logstash configuration files not the place to do it?

It's up to the author of the code to handle exceptions. As an end-user you cannot do much. The exception is in the beats input.

That said, does setting the option 'include\_codec\_tag =\> false' on the beats input help?

---

<div class="post-metadata">

**Author:** ![cd-agutierrez](https://avatars.discourse-cdn.com/v4/letter/c/e79b87/32.png) [@cd-agutierrez](https://discuss.elastic.co/u/cd-agutierrez)\
**Post date:** [August 12, 2019, 7:13pm UTC](https://discuss.elastic.co/t/how-to-handle-exceptions/194900/3 "2019-08-12T19:13:07Z")

</div>

What does 'include\_codec\_tag' do? The documentation for it appears to be blank.

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [August 12, 2019, 7:30pm UTC](https://discuss.elastic.co/t/how-to-handle-exceptions/194900/4 "2019-08-12T19:30:13Z")

</div>

[Adds](https://github.com/logstash-plugins/logstash-input-beats/blob/c9f5488b6955b4f5882f6c56ca06eec550b2d27d/lib/logstash/inputs/beats/raw_event_transform.rb#L14) a tag to the event. Disabling it may work around the bug, or it may just move the place where the bug blows things up.

---

<div class="post-metadata">

**Author:** ![cd-agutierrez](https://avatars.discourse-cdn.com/v4/letter/c/e79b87/32.png) [@cd-agutierrez](https://discuss.elastic.co/u/cd-agutierrez)\
**Post date:** [August 12, 2019, 7:58pm UTC](https://discuss.elastic.co/t/how-to-handle-exceptions/194900/5 "2019-08-12T19:58:06Z")

</div>

That worked! 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:** [September 9, 2019, 7:58pm UTC](https://discuss.elastic.co/t/how-to-handle-exceptions/194900/6 "2019-09-09T19:58:12Z")

</div>

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