【问题标题】:Logstash JDBC input plugin execution failed with error : Expected one of #, {, } at line 9, column 60Logstash JDBC 输入插件执行失败并出现错误:第 9 行第 60 列应为 #、{、} 之一
【发布时间】:2018-06-14 09:47:34
【问题描述】:

我正在通过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 语句,然后也得到了同样的错误。

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"

【问题讨论】:

  • 您需要删除 SELECT 语句中的换行符
  • @Val 我删除了我的SELECT 语句中的所有新行,然后也遇到了同样的错误。
  • 一模一样?
  • 是的,完全相同。但第 # 行不同。因为我删除了换行符
  • 这个错误是因为我在查询之间使用了双引号 "" 现在我添加了转义序列 \" 并开始执行。但现在又收到了另一个错误Exception when executing JDBC query {:exception=>#<Sequel::DatabaseError: Java::JavaSql::SQLSyntaxErrorException: ORA-00923: FROM keyword not found where expected,但它在查询中

标签: java elasticsearch logstash kibana elastic-stack


【解决方案1】:

解决方案 1

您需要在双引号内转义双引号。 "SELECT .. \"CODE\" ..."

为此,您需要在 logstash.yml 中输入 setconfig.support_escapes: true 。 (来自logstash docs

解决方案 2

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

【讨论】:

    猜你喜欢
    • 2019-06-17
    • 1970-01-01
    • 1970-01-01
    • 2022-10-25
    • 1970-01-01
    • 2016-09-15
    • 2017-01-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多