Logstash cannot connect to Azure MS Sql database

I am trying to extract info from all databases using Logstash and inserting them into Elasticsearch. While it works for all databases with specified localhost addresses, I am having trouble connecting to databases in AZURE cloud.
The JDBC input of my logstash.conf file looks as follows -

jdbc { 
    jdbc_connection_string => "jdbc:sqlserver://hostname.database.windows.net:1433;database=******;encrypt=true;hostNameInCertificate=*.database.windows.net"
    jdbc_user => "<Username>"
jdbc_password => "<Password>"
    jdbc_driver_library => "/config-dir/<Latest JAR File>"
    jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
    statement => "<SQL QUERY>"
schedule => "* * * * *"
type => "type_1"
}

The error I am getting after running the docker-compose file is -
logstash | [2019-02-11T05:53:40,429][ERROR][logstash.inputs.jdbc ] Unable to connect to database. Tried 1 times {:error_message=>"Java::ComMicrosoftSqlserverJdbc::SQLServerException: Cannot open server "logstash" requested by the login. The login failed."}
logstash | [2019-02-11T05:53:40,431][ERROR][logstash.pipeline ] A plugin had an unrecoverable error. Will restart this plugin.
logstash | Pipeline_id:main
logstash |
logstash | Error: Java::ComMicrosoftSqlserverJdbc::SQLServerException: Cannot open server "logstash" requested by the login. The login failed.
logstash | Exception: Sequel::DatabaseConnectionError

The credentials are fine, I have connected the Azure database from my local MSSQL instance. But somehow Logstash cannot do so. Can anyone help me identify what am I missing here? Thanks in advance.

I have solved the problem. While entering the "Username" field for AZURE databases, we should modify it like "Username@hostname" where "hostname" defines the SQL Azure Server ID as in the connection string.

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