Karthikeyan
Karthikeyan

Reputation: 2001

Logstash JDBC input plugin execution failed with error : Expected one of #, {, } at line 9, column 60

Am inserting oracle table information in elasticsearch via logstash configuration file, while executing the logstash config file and getting the below error message.

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)

Please find my logstash configuration for JDBC input plugin

  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"
  }
}

Please find the below error logs from 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'", 

Am using logstash 6.2.4 version

I gave the SELECT statment in single line, then also am getting the same error.

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"

Upvotes: 0

Views: 1728

Answers (1)

jaraics
jaraics

Reputation: 4299

Solution 1

You need to escape double quotes inside double quotes. "SELECT .. \"CODE\" ..."

And for that to work, you need to setconfig.support_escapes: true in your logstash.yml . (From logstash docs)

Solution 2

Use statement_filepath to read statement from an external file. In this external file you do not need the enclosing quotasion marks around the query.(See link)

Upvotes: 1

Related Questions