首页 > 解决方案 > 日志存储;当添加新配置文件以同步 postgres 数据时,logstash 停止工作

问题描述

 input {
      jdbc {
         jdbc_connection_string => “jdbc:postgresql://localhost:5432/FraudInsuranceBizapp”
         jdbc_user => “postgres”
         jdbc_password => “postgres”
         jdbc_driver_class => “org.postgresql.Driver”
         statement => “SELECT * from \”jhi_user\””
     }
    }
    
    
    output {
      elasticsearch {
        hosts => [“http://localhost:9200"]
        index => “jhi_user”
        document_id => “users_%{id}”
        doc_as_upsert => true
        #user => “es_user”
        #password => “es_password”
     }
    }

当我从命令行运行logstash .\bin\logstash.bat -f D:\MESCN\softwares\logstash-7.13.2\config\jhi-user.conf 得到以下错误

    Using JAVA_HOME defined java: "D:\MESCN\softwares\logstash-7.13.2\jdk"
    WARNING, using JAVA_HOME while Logstash distribution comes with a bundled JDK
    OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future
release.
    Sending Logstash logs to D:/MESCN/softwares/logstash-7.13.2/logs which is now configured via log4j2.properties
    [2021-06-24T10:11:35,655][INFO ][logstash.runner          ] Log4j configuration path used is:
D:\MESCN\softwares\logstash-7.13.2\config\log4j2.properties
    [2021-06-24T10:11:35,689][INFO ][logstash.runner          ] Starting Logstash {"logstash.version"=>"7.13.2",
"jruby.version"=>"jruby 9.2.16.0 (2.5.7) 2021-03-03 f82228dc32 OpenJDK
64-Bit Server VM 11.0.11+9 on 11.0.11+9 +indy +jit [mswin32-x86_64]"}
    [2021-06-24T10:11:35,989][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file
because modules or command line options are specified
    [2021-06-24T10:11:38,460][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}
    [2021-06-24T10:11:38,776][ERROR][logstash.agent           ] Failed to execute action
{:action=>LogStash::PipelineAction::Create/pipeline_id:main,
:exception=>"LogStash::ConfigurationError", :message=>"Expected one of
[ \\t\\r\\n], \"#\", [A-Za-z0-9_-], '\"', \"'\", [A-Za-z_], \"-\",
[0-9], \"[\", \"{\" at line 3, column 32 (byte 51) after input {\r\n 
jdbc {\r\n     jdbc_connection_string => ",
:backtrace=>["D:/MESCN/softwares/logstash-7.13.2/logstash-core/lib/logstash/compiler.rb:32:in
`compile_imperative'",
"org/logstash/execution/AbstractPipelineExt.java:187:in `initialize'",
"org/logstash/execution/JavaBasePipelineExt.java:72:in `initialize'",
"D:/MESCN/softwares/logstash-7.13.2/logstash-core/lib/logstash/java_pipeline.rb:47:in
`initialize'",
"D:/MESCN/softwares/logstash-7.13.2/logstash-core/lib/logstash/pipeline_action/create.rb:52:in
`execute'",
"D:/MESCN/softwares/logstash-7.13.2/logstash-core/lib/logstash/agent.rb:389:in
`block in converge_state'"]}
    [2021-06-24T10:11:39,047][INFO ][logstash.runner          ] Logstash shut down.
    [2021-06-24T10:11:39,071][FATAL][org.logstash.Logstash    ] Logstash stopped processing because of an error: (SystemExit) exit
    org.jruby.exceptions.SystemExit: (SystemExit) exit
            at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:747)
~[jruby-complete-9.2.16.0.jar:?]
            at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:710)
~[jruby-complete-9.2.16.0.jar:?]
            at D_3a_.MESCN.softwares.logstash_minus_7_dot_13_dot_2.lib.bootstrap.environment.<main>(D:\MESCN\softwares\logstash-7.13.2\lib\bootstrap\environment.rb:89)
~[?:?]

标签: logstash

解决方案


jdbc_connection_string => “jdbc:postgresql://localhost:5432/FraudInsuranceBizapp”

logstash 将不接受花括号。您需要使用常规双引号。这同样适用于输入和输出中的所有选项。


推荐阅读