How to escape character in logstash

I want to execute below sql statement in input of logstash configuration file but it fails to compile

statement => "select ALERT_ID, regexp_replace(regexp_substr(html_file_key,'(.?)'),'|','') as alertDate, regexp_replace(regexp_substr(html_file_key ,'(.?)'),'|','') as score from alerts"

I am getting below error log

[2019-03-07T19:31:17,534][ERROR][logstash.agent ] Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Expected one of #, {, } at line 11, column 91 (byte 436) after # JDBC -> Logstash -> Elasticsearch pipeline.\n\ninput {\n jdbc {\n\t\t#input Configuration\n\t\tjdbc_connection_string => "jdbc:oracle:thin:@oraasgtd37-scan.nam.net:8889/CW1S"\n\t\tjdbc_user => "ACT"\n\t\tjdbc_password => "rc_op"\n\t\tjdbc_driver_library => "I:\Jars\ojdbc6.jar"\n\t\tjdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"\n\t\tstatement => "select ALERT_ID, regexp_replace(regexp_substr(html_file_key ,'<elem name="", :backtrace=>["I:/GDPR/logstash-6.6.0/logstash-core/lib/logstash/compiler.rb:41:in compile_imperative'", "I:/GDPR/logstash-6.6.0/logstash-core/lib/logstash/compiler.rb:49:incompile_graph'", "I:/GDPR/logstash-6.6.0/logstash-core/lib/logstash/compiler.rb:11:in block in compile_sources'", "org/jruby/RubyArray.java:2486:inmap'", "I:/GDPR/logstash-6.6.0/logstash-core/lib/logstash/compiler.rb:10:in compile_sources'", "org/logstash/execution/AbstractPipelineExt.java:149:ininitialize'", "I:/GDPR/logstash-6.6.0/logstash-core/lib/logstash/pipeline.rb:22:in initialize'", "I:/GDPR/logstash-6.6.0/logstash-core/lib/logstash/pipeline.rb:90:ininitialize'", "I:/GDPR/logstash-6.6.0/logstash-core/lib/logstash/pipeline_action/create.rb:42:in block in execute'", "I:/GDPR/logstash-6.6.0/logstash-core/lib/logstash/agent.rb:92:inblock in exclusive'", "org/jruby/ext/thread/Mutex.java:148:in synchronize'", "I:/GDPR/logstash-6.6.0/logstash-core/lib/logstash/agent.rb:92:inexclusive'", "I:/GDPR/logstash-6.6.0/logstash-core/lib/logstash/pipeline_action/create.rb:38:in execute'", "I:/GDPR/logstash-6.6.0/logstash-core/lib/logstash/agent.rb:317:inblock in converge_state'"]}

Please help me to resolve this.

That looks like you have a double quote inside a string surrounded by double quotes. You need to escape it using \ or else change it to single quotes.

Thanks Badger. Its worked :slight_smile:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.