我想使用Jenkins-Logstash插件将Jenkins日志发送到Logstash。
这是我在Jenkins中配置Logstash插件的方式:
[jenkins-logstash-plugin configuration] [1] [1]:https://i.stack.imgur.com/EsIgY.png
我假设在logstash.conf中我必须在输入部分使用HTTP插件:
input {
http {
host => "127.0.0.1"
port => 31311
}
}
但是在Jenkins构建日志中我可以看到错误:
> [logstash-plugin]: Failed to send log data to
> ELASTICSEARCH:http://host_name:31311. [logstash-plugin]: No Further
> logs will be sent to http://host_name:31311.
> org.apache.http.conn.HttpHostConnectException: Connect to
> host_name:31311 [/host_name] failed: Connection refused (Connection
> refused) at
> org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:151)
> at
> org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
> ...
> Caused by: java.net.ConnectException: Connection refused
> (Connection refused) at java.net.PlainSocketImpl.socketConnect(Native
> Method) at
> java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
当我将Jenkins配置中的端口号更改为Elasticsearch端口9200
而不是31311
时,错误消失了。但在这种情况下,数据直接写入Elasticsearch。
如何设置Jenkins将构建日志发送到Logstash?
更新: 我现在能够发送和获取Logstash中的日志,一切正常。但是在Jenkins控制台中,我可以在向Logstash发送日志时看到错误,是否可以接受?
20:54:11 [logstash-plugin]: Failed to send log data to ELASTICSEARCH:host_name:31311.
20:54:11 [logstash-plugin]: No Further logs will be sent to host_name:31311.
20:54:11 java.io.IOException: HTTP error code: 200
20:54:11 URI: host_name:31311/jenkins-qa/type
20:54:11 RESPONSE: HttpResponseProxy{HTTP/1.1 200 OK [Content-Type: text/plain, Content-Length: 2] ResponseEntityProxy{[Content-Type: text/plain,Content-Length: 2,Chunked: false]}}
20:54:11 ok
20:54:11 at jenkins.plugins.logstash.persistence.ElasticSearchDao.push(ElasticSearchDao.java:113)
20:54:11 at jenkins.plugins.logstash.LogstashWriter.write(LogstashWriter.java:147)
20:54:11 at jenkins.plugins.logstash.LogstashWriter.writeBuildLog(LogstashWriter.java:116)
20:54:11 at jenkins.plugins.logstash.LogstashNotifier.perform(LogstashNotifier.java:63)
20:54:11 at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
20:54:11 at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
20:54:11 at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720)
20:54:11 at hudson.model.Build$BuildExecution.post2(Build.java:186)
20:54:11 at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:665)
20:54:11 at hudson.model.Run.execute(Run.java:1753)
20:54:11 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
20:54:11 at hudson.model.ResourceController.execute(ResourceController.java:98)
20:54:11 at hudson.model.Executor.run(Executor.java:405)
20:54:11 Finished: SUCCESS
答案 0 :(得分:0)
如OP所述,第一个问题是凭证1(用户名,密码,密钥)
第二条错误消息(“No Further logs will be sent to...
”)为seen here,表示:
.hpi
文件)插件,因为有关该异常的错误已在两天前修复过:PR 22;见commit 5078fcc。