代码之家  ›  专栏  ›  技术社区  ›  Livioso

Logstash with Google PubSub输入插件错误:证书验证失败

  •  1
  • Livioso  · 技术社区  · 7 年前

    我正在努力使Google PubSub插件正常工作,我遵循了所有的设置步骤(创建主题、创建专用服务帐户等)。我的配置如下:

    input {
       google_pubsub {
           project_id => "secret"
           topic => "fw-services-logs"
           subscription => "fw-logstash-sub"
           json_key_file => "/usr/share/logstash/service_account_key.json"
       }
    }
    
    output { stdout { codec => rubydebug } }
    
    
    # Works:
    # input { stdin { } }
    # output { stdout { codec => rubydebug } }
    

    然而,当我构建&运行它,我得到以下输出:

    Sending Logstash's logs to /usr/share/logstash/logs which is now configured via log4j2.properties
    [2017-10-27T11:39:46,455][INFO ][logstash.modules.scaffold] Initializing module {:module_name=>"fb_apache", :directory=>"/usr/share/logstash/modules/fb_apache/configuration"}
    [2017-10-27T11:39:46,462][INFO ][logstash.modules.scaffold] Initializing module {:module_name=>"netflow", :directory=>"/usr/share/logstash/modules/netflow/configuration"}
    [2017-10-27T11:39:46,694][INFO ][logstash.modules.scaffold] Initializing module {:module_name=>"arcsight", :directory=>"/usr/share/logstash/vendor/bundle/jruby/1.9/gems/x-pack-5.6.3-java/modules/arcsight/configuration"}
    [2017-10-27T11:39:46,714][INFO ][logstash.setting.writabledirectory] Creating directory {:setting=>"path.queue", :path=>"/usr/share/logstash/data/queue"}
    [2017-10-27T11:39:46,720][INFO ][logstash.setting.writabledirectory] Creating directory {:setting=>"path.dead_letter_queue", :path=>"/usr/share/logstash/data/dead_letter_queue"}
    [2017-10-27T11:39:46,795][INFO ][logstash.agent           ] No persistent UUID file found. Generating new UUID {:uuid=>"a144c8d2-12a9-4a15-a629-59910dda9295", :path=>"/usr/share/logstash/data/uuid"}
    [2017-10-27T11:39:48,114][INFO ][logstash.outputs.elasticsearch] Elasticsearch pool URLs updated {:changes=>{:removed=>[], :added=>[http://logstash_system:xxxxxx@elasticsearch:9200/]}}
    [2017-10-27T11:39:48,118][INFO ][logstash.outputs.elasticsearch] Running health check to see if an Elasticsearch connection is working {:healthcheck_url=>http://logstash_system:xxxxxx@elasticsearch:9200/, :path=>"/"}
    [2017-10-27T11:39:48,343][WARN ][logstash.outputs.elasticsearch] Attempted to resurrect connection to dead ES instance, but got an error. {:url=>"http://logstash_system:xxxxxx@elasticsearch:9200/", :error_type=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError, :error=>"Elasticsearch Unreachable: [http://logstash_system:xxxxxx@elasticsearch:9200/][Manticore::ResolutionFailure] elasticsearch: Name or service not known"}
    [2017-10-27T11:39:48,345][INFO ][logstash.outputs.elasticsearch] New Elasticsearch output {:class=>"LogStash::Outputs::ElasticSearch", :hosts=>["http://elasticsearch:9200"]}
    [2017-10-27T11:39:48,346][INFO ][logstash.pipeline        ] Starting pipeline {"id"=>".monitoring-logstash", "pipeline.workers"=>1, "pipeline.batch.size"=>2, "pipeline.batch.delay"=>5, "pipeline.max_inflight"=>2}
    [2017-10-27T11:39:48,389][INFO ][logstash.licensechecker.licensereader] Elasticsearch pool URLs updated {:changes=>{:removed=>[], :added=>[http://logstash_system:xxxxxx@elasticsearch:9200/]}}
    [2017-10-27T11:39:48,390][INFO ][logstash.licensechecker.licensereader] Running health check to see if an Elasticsearch connection is working {:healthcheck_url=>http://logstash_system:xxxxxx@elasticsearch:9200/, :path=>"/"}
    [2017-10-27T11:39:48,404][WARN ][logstash.licensechecker.licensereader] Attempted to resurrect connection to dead ES instance, but got an error. {:url=>"http://logstash_system:xxxxxx@elasticsearch:9200/", :error_type=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError, :error=>"Elasticsearch Unreachable: [http://logstash_system:xxxxxx@elasticsearch:9200/][Manticore::ResolutionFailure] elasticsearch"}
    [2017-10-27T11:39:48,435][WARN ][logstash.licensechecker.licensereader] Marking url as dead. Last error: [LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError] Elasticsearch Unreachable: [http://logstash_system:xxxxxx@elasticsearch:9200/][Manticore::ResolutionFailure] elasticsearch {:url=>http://logstash_system:xxxxxx@elasticsearch:9200/, :error_message=>"Elasticsearch Unreachable: [http://logstash_system:xxxxxx@elasticsearch:9200/][Manticore::ResolutionFailure] elasticsearch", :error_class=>"LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError"}
    [2017-10-27T11:39:48,445][ERROR][logstash.licensechecker.licensemanager] Unable to retrieve license information from license server {:message=>"Elasticsearch Unreachable: [http://logstash_system:xxxxxx@elasticsearch:9200/][Manticore::ResolutionFailure] elasticsearch", :class=>"LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError"}
    [2017-10-27T11:39:48,446][WARN ][logstash.licensechecker.xpackinfo] Nil response from License Server
    [2017-10-27T11:39:48,486][INFO ][logstash.pipeline        ] Pipeline .monitoring-logstash started
    [2017-10-27T11:39:48,536][INFO ][logstash.pipeline        ] Starting pipeline {"id"=>"main", "pipeline.workers"=>2, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>5, "pipeline.max_inflight"=>250}
    [2017-10-27T11:39:50,049][INFO ][logstash.inputs.googlepubsub] Client authorizataion with JSON key ready
    [2017-10-27T11:39:50,051][INFO ][logstash.pipeline        ] Pipeline main started
    [2017-10-27T11:39:50,235][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}
    [2017-10-27T11:39:50,875][ERROR][logstash.pipeline        ] A plugin had an unrecoverable error. Will restart this plugin.
      Plugin: <LogStash::Inputs::GooglePubSub project_id=>"secret", topic=>"fw-services-logs", subscription=>"fw-logstash-sub", json_key_file=>"/usr/share/logstash/service_account_key.json", id=>"23998ce4135823320ff87ea3bf3ca73094144ca9-1", enable_metric=>true, codec=><LogStash::Codecs::Plain id=>"plain_41007486-427e-4323-99fd-9375470f239e", enable_metric=>true, charset=>"UTF-8">, max_messages=>5>
      Error: certificate verify failed
    

    当我使用调试日志级别运行时,我看到它在法拉第的某个地方崩溃了:

    [2017-10-27T12:42:01,538][ERROR][logstash.pipeline] A plugin had an unrecoverable error. Will restart this plugin.
      Plugin: <LogStash::...>
      Error: certificate verify failed
      Exception: Faraday::SSLError
      Stack: org
    

    问题:

    • 知道我如何修复由于证书验证失败错误导致的插件崩溃吗?
    • 这些关于ElasticSearch的警告/信息日志是否正常?好吧,我不需要使用ES,对吗?

    FROM docker.elastic.co/logstash/logstash:5.6.3
    
    ADD service_account_key.json /usr/share/logstash/service_account_key.json
    
    # https://www.elastic.co/guide/en/logstash/current/docker.html
    RUN rm -f /usr/share/logstash/pipeline/logstash.conf
    ADD ./pipeline/ /usr/share/logstash/pipeline/
    
    RUN logstash-plugin install logstash-input-google_pubsub
    

    我像这样构建和运行它:

    docker build -t logstash -f logstash.docker --no-cache .
    docker run -it logstash
    
    1 回复  |  直到 7 年前
        1
  •  2
  •   Livioso    7 年前

    显式设置 SSL_CERT_FILE 修复了该问题。

    # see https://github.com/google/google-api-ruby-client/issues/253
    ENV SSL_CERT_FILE /usr/share/logstash/logstash-core/lib/logstash/certs/cacert.pem
    

    默认情况下,Logstash尝试将监控信息记录到Elasticsearch。 如果您(如我的情况)不希望发生这种情况,您可以使用以下方法禁用它:

    ENV XPACK_MONITORING_ENABLED false
    

    debug :

    ENV LOG_LEVEL debug