Logstash JDBC输入插件执行失败并显示错误:第9行第60列中的#,{,}中的一个

问题描述 投票:0回答:1

通过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版本

我用单行给了qazxsw poi语句,然后也得到了同样的错误。

SELECT

java elasticsearch logstash kibana elastic-stack
1个回答
1
投票

解决方案1

你需要在双引号内转义双引号。 “SELECT .. \”CODE \“......”

要做到这一点,你需要在你的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" setconfig.support_escapes: true。 (来自logstash.yml

解决方案2

使用logstash docs从外部文件中读取语句。在此外部文件中,您不需要查询周围的封闭引号。(statement_filepath

© www.soinside.com 2019 - 2024. All rights reserved.