如何将Logstash输出验证到安全的Elasticsearch URL(版本5.6.5)

Log*_*han 3 authentication https elasticsearch logstash logstash-configuration

我正在使用Logstash和Elasticsearch版本5.6.5。到目前为止,已将Elasticsearch输出与HTTP协议一起使用,并且未进行身份验证。现在,使用基本身份验证(用户/密码)和CA认证的HTTPS URL保护Elasticsearch。我对Elasticsearch服务器没有任何控制权。我只是用它从Logstash输出到。

现在,当我尝试使用基本身份验证配置elasticsearch的HTTPS URL时,它无法创建管道。

输出配置

output { 
 elasticsearch {
   hosts => ["https://myeslasticsearch.server.io"]
   user => "esusername"
   password => "espassword"
   ssl => true
 }
}
Run Code Online (Sandbox Code Playgroud)

失误

 1. Error registering plugin {:plugin=>"#<LogStash::OutputDelegator:0x50aa9200
 2. Pipeline aborted due to error {:exception=>#<URI::InvalidComponentError: bad component(expected user component):
Run Code Online (Sandbox Code Playgroud)

如何解决这个问题?我注意到有一个名为的字段cacert,它需要一些PEM文件。但是我不确定该放在哪里,因为Elasticsearch服务器使用的是CA认证的SSL,而不是自签名的SSL。

附加问题:我没有安装任何xpack。是否需要从Logstash向HTTPS输出到Elasticsearch的“ xpack”购买?

Log*_*han 6

我找到了问题的根本原因。有三件事要解决:

  1. 我测试过的Logstash版本是错误的5.5.0。我下载了正确的版本以与Elasticsearch版本5.6.5匹配。

  2. 我使用的主机在443端口上运行。当我没有在下面指定端口时,logstash会在它后面附加9200,这是由于连接失败。

    hosts => ['https://my.es.server.com']

    以下配置更正了logstash使用的端口。

    hosts => ['https://my.es.server.com:443']

  3. 我缺少代理连接设置。

    proxy => 'http://my.proxy.com:80'

有效的总体设置。

output {
    elasticsearch {
       hosts => ['https://my.es.server.com:443']
       user => 'esusername'
       password => 'espassword'
       proxy => 'http://my.proxy:80'
       index => "my-index-%{+YYYY.MM.dd}"
    }
}
Run Code Online (Sandbox Code Playgroud)

不需要“ ssl”字段。

无需为此安装“ xpack”