I try to connect Logstash to Postgresql. This database is located in a remote server and Logstash runs in a docker container. My logstash.conf is:
#
input{
jdbc{
jdbc_connection_string => "jdbc:postgresql://000.00.00.00:000"
jdbc_driver_library => "/usr/share/logstash/postgresql-42.2.19.jar"
jdbc_user => "user"
jdbc_password => "password"
jdbc_driver_class => "org.postgresql.Driver"
statement => "SELECT from table"
schedule => " * * * * UTC"
}
}
filter{
split{
field => "results"
}
}
output{
elasticsearch{
hosts => "elasticsearch:9200"
index => "teste2"
}
stdout {}
}
The error that´s occurring is:
[ERROR][logstash.inputs.jdbc ][main] Unable to connect to database. Tried 1 times {:error_message=>"Sequel::DatabaseError: driver.new.connect returned nil: probably bad JDBC connection string"}
{ rufus-scheduler intercepted an error:
job:
Rufus::Scheduler::CronJob "* * * * * UTC" {}
error:
2162
Sequel::DatabaseConnectionError
Sequel::DatabaseError: driver.new.connect returned nil: probably bad JDBC connection string
/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/sequel-5.41.0/lib/sequel/adapters/jdbc.rb:240:in connect' /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/sequel-5.41.0/lib/sequel/connection_pool.rb:122:in
make_new'
/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/sequel-5.41.0/lib/sequel/connection_pool/threaded.rb:209:in assign_connection' /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/sequel-5.41.0/lib/sequel/connection_pool/threaded.rb:139:in
acquire'
/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/sequel-5.41.0/lib/sequel/connection_pool/threaded.rb:91:in hold' /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/sequel-5.41.0/lib/sequel/database/connecting.rb:269:in
synchronize'
/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/sequel-5.41.0/lib/sequel/database/connecting.rb:278:in test_connection' /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/sequel-5.41.0/lib/sequel/database/misc.rb:169:in
initialize'
/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/sequel-5.41.0/lib/sequel/database/connecting.rb:57:in connect' /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/sequel-5.41.0/lib/sequel/core.rb:124:in
connect'
/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-integration-jdbc-5.0.6/lib/logstash/plugin_mixins/jdbc/jdbc.rb:114:in block in jdbc_connect' org/jruby/RubyKernel.java:1442:in
loop'
/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-integration-jdbc-5.0.6/lib/logstash/plugin_mixins/jdbc/jdbc.rb:111:in jdbc_connect' /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-integration-jdbc-5.0.6/lib/logstash/plugin_mixins/jdbc/jdbc.rb:139:in
open_jdbc_connection'
/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-integration-jdbc-5.0.6/lib/logstash/plugin_mixins/jdbc/jdbc.rb:197:in execute_statement /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-integration-jdbc-5.0.6/lib/logstash/inputs/jdbc.rb:316:in
execute_query'
/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-integration-jdbc-5.0.6/lib/logstash/inputs/jdbc.rb:279:in block in run' /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:234:in
do_call'
/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:258:in do_trigger' /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:300:in
block in start_work_thread'
/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:299:in block in start_work_thread' org/jruby/RubyKernel.java:1442:in
loop'
/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:289:in `block in start_work_thread'
tz:
ENV['TZ']:
Time.now: 2021-04-26 17:15:00 UTC
scheduler:
object_id: 2056
opts:
{:max_work_threads=>1}
frequency: 0.3
scheduler_lock: #Rufus::Scheduler::NullLock:0x483e10bf
trigger_lock: #Rufus::Scheduler::NullLock:0x13eb4132
uptime: 3153.372394 (52m33s372)
down?: false
threads: 2
thread: #Thread:0x4fa42b3e
thread_key: rufus_scheduler_2056
work_threads: 1
active: 1
vacant: 0
max_work_threads: 1
mutexes: {}
jobs: 1
at_jobs: 0
in_jobs: 0
every_jobs: 0
interval_jobs: 0
cron_jobs: 1
running_jobs: 1
work_queue: 0