# Http output plugin is not working in logstash, Please help

**URL:** https://discuss.elastic.co/t/http-output-plugin-is-not-working-in-logstash-please-help/275889
**Category:** Logstash
**Created:** [June 14, 2021, 6:54pm UTC](https://discuss.elastic.co/t/http-output-plugin-is-not-working-in-logstash-please-help/275889 "2021-06-14T18:54:29Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![rajkumar.m](https://avatars.discourse-cdn.com/v4/letter/r/e9bcb4/32.png) [@rajkumar.m](https://discuss.elastic.co/u/rajkumar.m)
#### Post date: [June 14, 2021, 6:54pm UTC](https://discuss.elastic.co/t/http-output-plugin-is-not-working-in-logstash-please-help/275889/1 "2021-06-14T18:54:29Z")

</div>

## Hi, I am trying to send json message to kibana api using http plugin, I found the below error, Please help and appreciated.

```auto
[2021-06-14T14:45:26,361][ERROR][logstash.outputs.http] [HTTP Output Failure] Encountered non-2xx HTTP code 400 {:response_code=>400, :url=>"https://XXXXXXXXXXXXXXXXXXXXXX:5601/api/saved_objects/_bulk_create", :event=>#<LogStash::Event:0x530a92cd>}

Please fine the below plugin options I used:
-------------------------------------------------------------------------------------
input plugin:
input {
       http {
             port => XXXX
             codec => json_lines
             ssl => true
             ssl_certificate => "XXXXXX"
             ssl_key => "XXXXXX"
       }
}
-------------------------------------------------------------------------------------
output plugin:
output {
    http {
         url => "https://XXXXXXXXXXXXXXXXXXXXXXX:5601/api/saved_objects/_bulk_create"
         http_method => "post"
         codec => "json_lines"
         cacert => "/var/tmp/XXXXXXXXXXX.pem"
         headers => {
           "Authorization" => "Basic XXXXXXXXXXXXXXXXXXXXXX"
           "Content-Type" => "application/json"
           "kbn-xsrf" => "reporting"  
         }
    }
}
-------------------------------------------------------------------------------------

```

---

<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: [June 14, 2021, 7:15pm UTC](https://discuss.elastic.co/t/http-output-plugin-is-not-working-in-logstash-please-help/275889/2 "2021-06-14T19:15:34Z")

</div>

saved\_object/\_bulk\_create expects to get an array of JSON objects. The json\_lines [codec](https://github.com/logstash-plugins/logstash-codec-json_lines/blob/e61006e3795b505c70ccb895bc7fa7859c1896ec/lib/logstash/codecs/json_lines.rb#L48) will encode a single JSON object. \_bulk\_create will not accept that. You could try something like

```auto
filter {
    ruby { code => 'event.set("[@metadata][eventAsJson]", event.to_json)' }
}
output {
    http {
       codec => line { format => "[%{[@metadata][eventAsJson]} ]" }
        ....

```

Of course this assumes that your event is a valid object, which seems unlikely, since logstash may have added fields to the event (e.g. @timestamp) that kibana is not expecting.

---

<div class="post-metadata">

### Author: ![rajkumar.m](https://avatars.discourse-cdn.com/v4/letter/r/e9bcb4/32.png) [@rajkumar.m](https://discuss.elastic.co/u/rajkumar.m)
#### Post date: [June 15, 2021, 6:45pm UTC](https://discuss.elastic.co/t/http-output-plugin-is-not-working-in-logstash-please-help/275889/3 "2021-06-15T18:45:12Z")

</div>

Hi Badger, Thanks for reply.

I have added the above entries, but still not working.  
I dont see any errors in logstash and started successfully.  
but I dont see any entries in the log that messages are dropping, I am trying to understand where the messages are dropping.  
I am trying to create multiple objects by sending json form of kibana objects to kibana api.  
please help and let me know if I am missing anything else.

please let me know how can I drop the fields that are added by logstash.

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: [June 15, 2021, 7:02pm UTC](https://discuss.elastic.co/t/http-output-plugin-is-not-working-in-logstash-please-help/275889/4 "2021-06-15T19:02:34Z")

</div>

You can remove fields using

```
mutate { remove_field => ["someField", "anotherField"] }

```

I suggest you replace the http output with a file or stdout output using the same codec and see if the request is a valid kibana request.

---

<div class="post-metadata">

### Author: ![rajkumar.m](https://avatars.discourse-cdn.com/v4/letter/r/e9bcb4/32.png) [@rajkumar.m](https://discuss.elastic.co/u/rajkumar.m)
#### Post date: [June 15, 2021, 7:46pm UTC](https://discuss.elastic.co/t/http-output-plugin-is-not-working-in-logstash-please-help/275889/5 "2021-06-15T19:46:49Z")

</div>

Thanks for reply,  
I am able to remove those fields.  
now I am able to see the message body in the log file and compared with the input json data.  
I found one additional field "tags":["\_rubyexception"]}" in the body and found the below error.

Please advise.

:message=\>"XXXXXXXXXXXXXXXXXXXXXXXXXXX:5601 failed to respond", :class=\>"Manticore::ClientProtocolException", :backtrace=\>["/opt/logstash/vendor/bundle/jruby/2.5.0/gems/manticore-0.6.4-java/lib/manticore/response.rb:37:in `block in initialize'", "/opt/logstash/vendor/bundle/jruby/2.5.0/gems/manticore-0.6.4-java/lib/manticore/response.rb:79:in `call'", "/opt/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-http-5.2.4/lib/logstash/outputs/http.rb:239:in `send_event'", "/opt/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-http-5.2.4/lib/logstash/outputs/http.rb:175:in `send\_events'", "/opt/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-http-5.2.4/lib/logstash/outputs/http.rb:124:in `multi_receive'", "org/logstash/config/ir/compiler/OutputStrategyExt.java:118:in `multi\_receive'", "org/logstash/config/ir/compiler/AbstractOutputDelegatorExt.java:101:in `multi_receive'", "/opt/logstash/logstash-core/lib/logstash/pipeline.rb:390:in `block in output\_batch'", "org/jruby/RubyHash.java:1419:in `each'", "/opt/logstash/logstash-core/lib/logstash/pipeline.rb:389:in `output\_batch'", "/opt/logstash/logstash-core/lib/logstash/pipeline.rb:341:in `worker_loop'", "/opt/logstash/logstash-core/lib/logstash/pipeline.rb:304:in `block in start\_workers'"], :will\_retry=\>true}

---

<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: [June 15, 2021, 8:11pm UTC](https://discuss.elastic.co/t/http-output-plugin-is-not-working-in-logstash-please-help/275889/6 "2021-06-15T20:11:52Z")

</div>

If you have a \_rubyexception tag then the ruby filter should have logged an exception.

I have no idea why Manticore is logging that 'failed to respond' error.

---

<div class="post-metadata">

### Author: ![rajkumar.m](https://avatars.discourse-cdn.com/v4/letter/r/e9bcb4/32.png) [@rajkumar.m](https://discuss.elastic.co/u/rajkumar.m)
#### Post date: [June 15, 2021, 11:06pm UTC](https://discuss.elastic.co/t/http-output-plugin-is-not-working-in-logstash-please-help/275889/7 "2021-06-15T23:06:48Z")

</div>

I have removed the ruby filter and removed the \_rubyexception tag.  
Now the message body is matching with input json.  
but still I am getting 'failed to respond' error.  
Please advise if there is any other options I need to try.

---

<div class="post-metadata">

### Author: ![rajkumar.m](https://avatars.discourse-cdn.com/v4/letter/r/e9bcb4/32.png) [@rajkumar.m](https://discuss.elastic.co/u/rajkumar.m)
#### Post date: [June 17, 2021, 2:53pm UTC](https://discuss.elastic.co/t/http-output-plugin-is-not-working-in-logstash-please-help/275889/8 "2021-06-17T14:53:17Z")

</div>

Please let me know if anyone facing same kind of issue,  
I am able to create saved objects by ingesting the json format into saved\_objects Kibana api with curl command. but when I use logstash to do the same job using http output plugin, it is failing.  
Appreciated help.

---

<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: [July 15, 2021, 2:54pm UTC](https://discuss.elastic.co/t/http-output-plugin-is-not-working-in-logstash-please-help/275889/9 "2021-07-15T14:54:09Z")

</div>

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