简体   繁体   English

Jenkins Logstash插件不会向Logstash发送数据

[英]Jenkins Logstash plugin doesn't send data to Logstash

I want to use Jenkins-Logstash plugin to send Jenkins logs to Logstash. 我想使用Jenkins-Logstash插件将Jenkins日志发送到Logstash。

This is how I configured Logstash plugin in Jenkins: 这是我在Jenkins中配置Logstash插件的方式:

[jenkins-logstash-plugin configuration][1] [1]: https://i.stack.imgur.com/EsIgY.png [jenkins-logstash-plugin configuration] [1] [1]: https ://i.stack.imgur.com/EsIgY.png

I assume in logstash.conf I have to use HTTP plugin in input section: 我假设在logstash.conf中我必须在输入部分使用HTTP插件:

input {
  http {
    host => "127.0.0.1"
    port => 31311
  }
}

But in Jenkins build logs I can see the error: 但在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)

And the error is gone when I change port number in Jenkins config to Elasticsearch port 9200 instead of 31311 . 当我将Jenkins配置中的端口号更改为Elasticsearch端口9200而不是31311时,错误消失了。 But in this case data is written directly to Elasticsearch. 但在这种情况下,数据直接写入Elasticsearch。

How can I set Jenkins to send build logs to Logstash? 如何设置Jenkins将构建日志发送到Logstash?

Update : I am able to send and get logs in Logstash now, everything works good. 更新 :我现在可以发送和获取Logstash中的日志,一切正常。 But in Jenkins console I can see the error when sending logs to Logstash, is it acceptable? 但是在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

As mentioned by the OP, the first issue was a credential one (username, password, key) 正如OP所提到的,第一个问题是凭证一(用户名,密码,密钥)

The second error message (" No Further logs will be sent to... ") is seen here , and means that: 此处可以看到第二条错误消息(“ No Further logs will be sent to... ”),表示:

  • the url has to be defined in the JENKINS Logstash Plugin , 必须在JENKINS Logstash插件中定义url,
  • you can try and compile (and manually installed the .hpi file) the plugin yourself, since a bug regarding that exception has just been fixed two days ago: PR 22 ; 您可以自己尝试编译(并手动安装.hpi文件)插件,因为有关该异常的错误已在两天前修复过: PR 22 ; see commit 5078fcc . commit 5078fcc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM