【问题标题】:Logstash | ConfigurationError :message=>Expected one of [ \\t\\r\\n], \"#\", \"input\", \"filter\", \"output\" at line 1, column 1 (byte 1)日志存储 | ConfigurationError :message=>预计第 1 行第 1 列中的 [\\t\\r\\n]、\"#\"、\"input\"、\"filter\"、\"output\" 之一(字节 1)
【发布时间】:2020-04-25 15:16:21
【问题描述】:

我在启动 Logstash 时遇到配置错误。我使用的是 7.5.1 版本。 相同的配置文件之前工作过。我不得不在另一个 VM 上设置 ELK stash,因为旧的 VM 已退役,我在这里遇到了这个错误。

我正在使用 -

实例化 logstash

logstash-7.5.1\bin\logstash -f logstash-config.conf

.

配置文件 -

#config file

input{
jdbc{
jdbc_driver_library=>"C:\software\ojdbc7.jar"
jdbc_driver_class=>"Java::oracle.jdbc.driver.OracleDriver"
jdbc_connection_string=>"jdbc:oracle:thin:@<host>:1528:TSTIM"
jdbc_user=>"UName"
jdbc_password=>"PWD"
statement=>"SELECT * from TABLE where run_id > 4500"
}
}

output{
elasticsearch{
hosts=>"http://localhost:9200"
index=>"run_id"
document_type=>"TABLEname"
document_id=>"run_id"
user=>"elastic"
password=>"changeme"
}
stdout{
codec=>rubydebug
}
}

.

错误 -

C:\software>logstash-7.5.1\bin\logstash -f logstash-config.conf
Thread.exclusive is deprecated, use Thread::Mutex
Sending Logstash logs to C:/software/logstash-7.5.1/logs which is now configured via log4j2.properties
[2020-01-08T05:04:33,207][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
[2020-01-08T05:04:33,426][INFO ][logstash.runner ] Starting Logstash {"logstash.version"=>"7.5.1"}
[2020-01-08T05:04:34,869][ERROR][logstash.agent ] Failed to execute action 
{:action=>LogStash::PipelineAction::Create/pipeline_id:main,
:exception=>"LogStash::ConfigurationError",
:message=>"Expected one of [ \t\r\n], "#", "input", "filter", "output" at line 1, column 1 (byte 1)", 
:backtrace=>[
"C:/software/logstash-7.5.1/logstash-core/lib/logstash/compiler.rb:41:in compile_imperative'",
"C:/software/logstash-7.5.1/logstash-core/lib/logstash/compiler.rb:49:in compile_graph'",
"C:/software/logstash-7.5.1/logstash-core/lib/logstash/compiler.rb:11:in block in compile_sources'",
"org/jruby/RubyArray.java:2584:in map'",
"C:/software/logstash-7.5.1/logstash-core/lib/logstash/compiler.rb:10:in compile_sources'", 
"org/logstash/execution/AbstractPipelineExt.java:156:in initialize'",
"org/logstash/execution/JavaBasePipelineExt.java:47:in initialize'", 
"C:/software/logstash-7.5.1/logstash-core/lib/logstash/java_pipeline.rb:27:in initialize'", 
"C:/software/logstash-7.5.1/logstash-core/lib/logstash/pipeline_action/create.rb:36:in execute'", 
"C:/software/logstash-7.5.1/logstash-core/lib/logstash/agent.rb:326:in block in converge_state'"
]}
[2020-01-08T05:04:35,510][INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=>9600}
[2020-01-08T05:04:40,325][INFO ][logstash.runner ] Logstash shut down.

【问题讨论】:

    标签: configuration logstash elastic-stack elk


    【解决方案1】:

    我的错。配置文件有一些坏字符。我只好打扫了。 手动将相同的配置内容输入到另一个文件中。

    【讨论】:

    • 哪些坏字符?我自己有点卡在这个问题上。
    • 在 Windows 机器上从头开始输入内容对我有用。您可以使用 sed 或 dos2unix 命令使用 unix 系统清理文件,然后将其放置。
    • 谢谢。我的问题略有不同。我只在 linux 上,所以 dos2unix 没有帮助。原来你不能在 YAML 文件中包含 cmets。让我哑口无言。该消息仍然相当神秘。
    • 我不得不从 CRLF -> LF 更改行尾
    【解决方案2】:

    我在使用 Notepad++ 的 Windows 上遇到了同样的问题。

    我的解决方案是将配置保存到UTF-8 without BOMUnix format (LF)

    【讨论】:

      【解决方案3】:

      当我从网页复制/粘贴一些字符串到我的配置文件中时,我遇到了同样的问题。 原因是行首有“制表符”或“空白”以外的不可打印字符。如果您在 VS Code 中选择文件的全部内容,您可以看到好行和坏行之间的区别。

      我把坏字符换成空格,问题就解决了。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-10-25
        • 2021-07-13
        • 2016-03-03
        • 1970-01-01
        • 1970-01-01
        • 2019-08-09
        • 2021-12-26
        • 2020-01-02
        相关资源
        最近更新 更多