问题
I've installed the logstash-plugin for jenkins and configured it to use the indexer as elastic search.
While executing the jobs I see the following error:
16:56:12 [logstash-plugin]: Failed to send log data to ELASTICSEARCH:http://localhost:9200.
16:56:12 [logstash-plugin]: No Further logs will be sent to http://localhost:9200.
16:56:12 java.io.IOException: HTTP error code: 200
16:56:12 URI: http://localhost:9200/logstash-jenkins
16:56:12 RESPONSE: HttpResponseProxy{HTTP/1.1 200 OK [Content-Type: application/json; charset=UTF-8, Content-Length: 21] ResponseEntityProxy{[Content-Type: application/json; charset=UTF-8,Content-Length: 21,Chunked: false]}}
16:56:12 {"acknowledged":true}
16:56:12 at jenkins.plugins.logstash.persistence.ElasticSearchDao.push(ElasticSearchDao.java:113)
16:56:12 at jenkins.plugins.logstash.LogstashWriter.write(LogstashWriter.java:147)
16:56:12 at jenkins.plugins.logstash.LogstashWriter.write(LogstashWriter.java:85)
16:56:12 at jenkins.plugins.logstash.LogstashOutputStream.eol(LogstashOutputStream.java:58)
16:56:12 at hudson.console.LineTransformationOutputStream.eol(LineTransformationOutputStream.java:60)
16:56:12 at hudson.console.LineTransformationOutputStream.write(LineTransformationOutputStream.java:56)
16:56:12 at hudson.console.LineTransformationOutputStream.write(LineTransformationOutputStream.java:74)
16:56:12 at java.io.PrintStream.write(PrintStream.java:480)
16:56:12 at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
16:56:12 at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)
16:56:12 at sun.nio.cs.StreamEncoder.flushBuffer(StreamEncoder.java:104)
16:56:12 at java.io.OutputStreamWriter.flushBuffer(OutputStreamWriter.java:185)
16:56:12 at java.io.PrintStream.newLine(PrintStream.java:546)
16:56:12 at java.io.PrintStream.println(PrintStream.java:807)
16:56:12 at hudson.model.Cause$UserIdCause.print(Cause.java:426)
16:56:12 at hudson.model.StreamBuildListener.started(StreamBuildListener.java:75)
16:56:12 at hudson.model.Run.execute(Run.java:1723)
16:56:12 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
16:56:12 at hudson.model.ResourceController.execute(ResourceController.java:98)
16:56:12 at hudson.model.Executor.run(Executor.java:410)
Would appreciate any clues on how I can fix this error.
Thanks - Prateek
回答1:
At Jenkins plugin you need to define elasticsearch url that contains [yourindex]/[yourtype] as follows: http://localhost:9200/yourindex/yourtype Hope it helps.
回答2:
Are you trying to use Logstash to feed logs into Elasticsearch? Despite being called 'Logstash Plugin' the Jenkins Logstash plugin doesn't support this. I found that when I tried to send logs straight to Elasticsearch the plugin worked fine but when I tried to go through Logstash I got the same error as you.
There's currently a pull request in the Jenkins Logstash github to fix this bug (https://github.com/jenkinsci/logstash-plugin/pull/22), but as the plugin hasn't been active for 10 months (at time of writing) I don't have much hope.
If you want to send logs straight to Elasticsearch, you need to configure Elasticsearch to listen to remote connections. Set the following in your elasticsearch.yml:
network.host: 0.0.0.0 http.port: 7590
Then set the Elasticsearch url in Jenkins to http://:7590/
Hope that helps!
来源:https://stackoverflow.com/questions/36319816/jenkins-logstash-plugin-unable-to-post-to-elasticsearch