# Handling exception from HTTP logstash 6.8

**URL:** <https://discuss.elastic.co/t/handling-exception-from-http-logstash-6-8/242259>\
**Category:** Logstash\
**Created:** [July 22, 2020, 9:48pm UTC](https://discuss.elastic.co/t/handling-exception-from-http-logstash-6-8/242259 "2020-07-22T21:48:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pvaithee07](https://avatars.discourse-cdn.com/v4/letter/p/e495f1/32.png) [@pvaithee07](https://discuss.elastic.co/u/pvaithee07)\
**Post date:** [July 22, 2020, 9:48pm UTC](https://discuss.elastic.co/t/handling-exception-from-http-logstash-6-8/242259/1 "2020-07-22T21:48:19Z")

</div>

Hello -

I am trying to handle exception in my logstash after HTTP filter plugin. I am using Logstash version 6.8. I have couple of question on this -

1. How to handle exception if the HTTP response code is other than 200?
2. When there is any HTTP exception, i see tags getting the exception. But without knowing the actual values of the tags, how can i check for and handle that? For ex, if my Http times out, i don't know what exception gets added to the tag.

Thanks.

---

<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:** [July 22, 2020, 10:45pm UTC](https://discuss.elastic.co/t/handling-exception-from-http-logstash-6-8/242259/2 "2020-07-22T22:45:19Z")

</div>

The default value for tag\_on\_request\_failure \_httprequestfailure. You get the same tag if the http client throws an exception (I think that includes a time) or if the http status is outside of the range 200-299.

That means you cannot distinguish between a timeout, a 403, a 500 etc.

---

<div class="post-metadata">

**Author:** ![pvaithee07](https://avatars.discourse-cdn.com/v4/letter/p/e495f1/32.png) [@pvaithee07](https://discuss.elastic.co/u/pvaithee07)\
**Post date:** [July 22, 2020, 11:05pm UTC](https://discuss.elastic.co/t/handling-exception-from-http-logstash-6-8/242259/3 "2020-07-22T23:05:11Z")

</div>

Thank you.  
So, if the HTTP fails because of Authentication or if fails due to timeout or response code other than 200-299, we get the same tag '\_httprequestfailure'. Is that correct?

Is there a way to get the HTTP response code in 6.8? i see in 7.8, there was an option.

---

<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:** [July 22, 2020, 11:13pm UTC](https://discuss.elastic.co/t/handling-exception-from-http-logstash-6-8/242259/4 "2020-07-22T23:13:22Z")

</div>

> [@pvaithee07](#):
>
> Is that correct?

Yes, that is correct.

There is no way to get the response code for a failure. If you look at the [code](https://github.com/logstash-plugins/logstash-filter-http/blob/a74f40d94f04e9407990e1deb2f061ce6e95967e/lib/logstash/filters/http.rb#L58) process\_response does not get called if there is an error or a response code outside of 200-299. It is not like an http\_poller input where you can get the metadata for both successes and failures.

---

<div class="post-metadata">

**Author:** ![pvaithee07](https://avatars.discourse-cdn.com/v4/letter/p/e495f1/32.png) [@pvaithee07](https://discuss.elastic.co/u/pvaithee07)\
**Post date:** [July 22, 2020, 11:18pm UTC](https://discuss.elastic.co/t/handling-exception-from-http-logstash-6-8/242259/5 "2020-07-22T23:18:17Z")

</div>

ok. Thank you so much for quick reply. That helps.

---

<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:** [August 19, 2020, 11:18pm UTC](https://discuss.elastic.co/t/handling-exception-from-http-logstash-6-8/242259/6 "2020-08-19T23:18:21Z")

</div>

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