gpt4 book ai didi

java - Logstash JDBC 输入插件执行失败,第 9 行第 60 列出现错误 : Expected one of#, {, }

转载 作者:行者123 更新时间:2023-12-02 11:07:32 26 4
gpt4 key购买 nike

我通过logstash配置文件在elasticsearch中插入oracle表信息,同时执行logstash配置文件并收到以下错误消息。

Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Expected one of #, {, } at line 8, column 84 (byte 334)

请找到我的 JDBC 输入插件的 Logstash 配置

  input {
jdbc {
jdbc_driver_library => "D:\1SearchEngine\data\ojdbc8.jar"
jdbc_driver_class => "Java::oracle.jdbc.OracleDriver"
jdbc_connection_string => "jdbc:oracle:thin:@localhost:1521:XE"
jdbc_user => "vb"
jdbc_password => "1234567"
statement => "select vp.id, LISTAGG(vp.code,',')within GROUP(order by vp.code)"CODE", LISTAGG(vbl.product_id,',')within GROUP(order by vbl.product_id)"PRODUCT_ID",LISTAGG(vbl.type,',')within GROUP(order by vbl.type)"TYPE" from product vp,PRODUCT_LINK vbl where vp.id = vbl.product_id group by id,vbl.product_id,vbl.type"
}
}

output {
elasticsearch {
hosts => ["localhost:9200"]
index => "replacement"
}
}

请从logstash找到以下错误日志

[2018-06-14T15:42:07,683][ERROR][logstash.agent] Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Expected one of #, {, } at line 8, column 84 (byte 334) after \tinput {\n\t  jdbc {\n\t\tjdbc_driver_library => \"D:\\1SearchEngine\\data\\ojdbc8.jar\"\n\t\tjdbc_driver_class => \"Java::oracle.jdbc.OracleDriver\"\n\t\tjdbc_connection_string => \"jdbc:oracle:thin:@localhost:1521:XE\"\n\t\tjdbc_user => \"vb\"\n\t\tjdbc_password => \"1234567\"\n\t\tstatement => \"select vp.id, LISTSTAGG(vp.code,',')within GROUP(order by vp.code)\"", :backtrace=>["D:/1SearchEngine/logstash-6.2.4/logstash-6.2.4/logstash-core/lib/logstash/compiler.rb:42:in `compile_imperative'", 

我使用的是logstash 6.2.4版本

我在单行中给出了 SELECT 语句,然后也遇到了相同的错误。

语句 => "select vp.id, LISTAGG(vp.code,',')within GROUP (order by vp.code)"CODE",LISTAGG(vbl.product_id,' , ')within GROUP (按 vbl.product_id 排序)“PRODUCT_ID”,LISTAGG(vbl.type,' , ')在 GROUP 内(按 vbl.type 排序)“TYPE”来自产品 vp,PRODUCT_LINK vbl 其中 vp.id = vbl.product_id 按 id 分组,vbl.product_id,vbl.type"

最佳答案

解决方案1

您需要转义双引号内的双引号。 “选择..\“代码\”...”

要使其发挥作用,您需要在 logstash.yml 中设置 setconfig.support_escapes: true 。 (来自logstash docs)

解决方案2

使用statement_filepath从外部文件读取语句。在此外部文件中,您不需要在查询周围使用引号。( See link )

关于java - Logstash JDBC 输入插件执行失败,第 9 行第 60 列出现错误 : Expected one of#, {, },我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50854487/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com