Loading...

Perform Health-Check on Database Connections with logstash

:heavy_exclamation_mark: This post is older than a year. Consider some information might not be accurate anymore. :heavy_exclamation_mark:

Used:   logstash 1.5.3 

This section describes how to perform health checks on database instances. logstash offers the jdbc input plugin.

Type Url
Source Code github
Reference elastic reference

Plugin Installation

In the current logstash version, the JDBC plugin is not included in the default distribution. To install the plugin invoke the ruby gem installation. The plugin name is logstash-input-jdbc. Following example was done on a windows machine.

bin\plugin.bat install logstash-input-jdbc

Configuration

This section shows how to perform a health check on the database instance (Oracle DB 11g).

 input {
  jdbc {
    jdbc_driver_library => "C:/Daten/tools/logstash-1.5.3/db/ojdbc6.jar"
    jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"
    jdbc_connection_string => "jdbc:oracle:thin:@//localhost:1521/db"
    jdbc_user => "scott"
    jdbc_password => "tiger"
    # will execute on the 0th minute of every hour every day
    # uncomment for testing purpose
    # schedule => "0 * * * *"
    statement => "select 1 from dual"
    jdbc_paging_enabled => "true"
    jdbc_page_size => "1"
    jdbc_validate_connection => "true"
 }
}
output {
    stdout { codec => rubydebug }
}

Pay attention to add the prefix Java:: to the driver class! See also github issue #43

Testing

This will give you

C:\Daten\tools\logstash-1.5.3>bin\logstash.bat -f jdbc.conf
io/console not supported; tty will not be manipulated
Logstash startup completed
{
             "1" => 1.0,
      "@version" => "1",
    "@timestamp" => "2015-08-18T11:24:37.865Z"
}
Logstash shutdown completed
Please remember the terms for blog comments.