如何设置 logstash 配置输出以同时使用 HTTP 和其他 HTTPS 端点?

How to set logstash configuration output to use both HTTP & other HTTPS endpoints?

我想从 logstash 向 2 个端点发送数据,其中一个是 HTTP 端点,另一个是 HTTPS。

我尝试将 HTTPS 端点的用户名和密码放在 url 本身,但 logstash 也将这些字段 [用户名和密码] 用于其他端点。

我当前的输出字段如果喜欢:

output {
    elasticsearch{
        index => "index_name"
        document_id => "%{index_id}"
        hosts => ["https://elastic:pass@clusterid.asia-northeast1.gcp.cloud.es.io:9243",
                  "http://127.0.0.1:9200"]
                }
      }

在日志中获取此消息:

Elasticsearch pool URLs updated {:changes=>{:removed=>[], :added=>[https://elastic:xxxxxx@clusterid.asia-northeast1.gcp.cloud.es.io:9243/, https://elastic:xxxxxx@127.0.0.1:9200/]}}

还有这个:

[logstash.agent] Failed to execute action {:id=>:"cloud-elastic", :action_type=>LogStash::ConvergeResult::FailedAction, :message=>"Could not execute action: PipelineAction::Create<cloud-elastic>, action_result: false", :backtrace=>nil}

please try using different elasticsearch output for https and http,below settings

if "Https" in [tag]{
    elasticsearch {
                hosts => [ "https://elastic:pass@clusterid.asia-northeast1.gcp.cloud.es.io:9243" ]
                user => "${ES_USER:admin}"
                password => "${ES_PWD:admin}"
                ssl => true
                ssl_certificate_verification => false
                cacert => "${CERTS_DIR}/certs/ca.crt"
                index => "%{[docInfo][index]}"
                action => "index"
              }
            } else {
               elasticsearch {
                hosts => [ "http://127.0.0.1:9200" ]
                index => "%{[docInfo][index]}"
                action => "index"
              }
}

在 .bashrc 文件中

设置以下环境变量

export ES_USER=elastic
export ES_PWD=pass
export CERTS_DIR=/home/abc