I'm currently trying to connect to a remote MSsql server with the JDBC plugin of Logstash.
For the config file, I use the syntax proposed by mick66 on this thread: Jdbc MSSql Server Connection
My config file is thus:
input {
jdbc {
jdbc_driver_library => "/etc/logstash/sqljdbc4-3.0.jar"
jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
jdbc_connection_string => "jdbc:sqlserver://IPADDRESS:1433;databasename=MYDBNAME"
jdbc_user => "USER"
jdbc_password => "PASSWORD"
schedule => "* * * * *"
statement => "SELECT COUNT(*) FROM Table"
}
}
output {
elasticsearch {
protocol => http
index => "SqlData"
document_type => "Counter"
hosts => ["localhost:9200"]
}
}
However, I have the error:
message=>"Pipeline aborted due to error", :exception=>#<LogStash::ConfigurationError: Something is wrong with your configuration.>, :backtrace=>["/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.4-java/lib/logstash/config/mixin.rb:134:in `config_init'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.4-java/lib/logstash/outputs/base.rb:63:in `initialize'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.4-java/lib/logstash/output_delegator.rb:74:in `register'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.4-java/lib/logstash/pipeline.rb:181:in `start_workers'", "org/jruby/RubyArray.java:1613:in `each'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.4-java/lib/logstash/pipeline.rb:181:in `start_workers'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.4-java/lib/logstash/pipeline.rb:136:in `run'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.4-java/lib/logstash/agent.rb:473:in `start_pipeline'"], :level=>:error}
{:timestamp=>"2016-08-02T13:37:07.250000+0200", :message=>"stopping pipeline", :id=>"main"}
Which seems to say that the syntax of the config file is not correct. The problem seems to be the "databasename=DATABASE" part. However, I found that the syntax for a connection to a MSsql database is:
jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]]
Which is the syntax that I respected.
I try then to replace the "jdbc_connection_string" by:
jdbc_connection_string => "jdbc:sqlserver://IPADDRESS:1433/MYDBNAME"
The config seems then to be correct (no ConfigurationError) but logstash triggers an error that says that the port "1433/MYDBNAME" is incorrect. This syntax seems thus also innapropriate.
This leads to my main question: What is the appropriate syntax for the logstash config file if we want to connect to a MSsql server using the JDBC plugin ?
Edit: I already checked that the MSsql server is well running and that its IP/TCP config is well active as mentionned in a great deal of posts on the Internet.