I want to connect to MySQL database for collecting logs in logstash. But database is having secured connection. How do I set SSL in JDBC input plugin of logstash for MySQL database?
I'd expect this should to work the same way as with all other JDBC clients, i.e. you'll have to adjust the connection string (see e.g. https://stackoverflow.com/a/34324275/414355).
I tired this in config file:
input{
jdbc {
jdbc_connection_string => "jdbc:mysql://10.112.112.43:3306/testDB?useSSL=true&verifyServerCertificate=false&requireSSL=true"
jdbc_user => "root"
jdbc_password => "root"
jdbc_validate_connection => true
jdbc_driver_library => "/usr/share/logstash/bin/mysql-connector-java-5.1.44/mysql-connector-java-5.1.44-bin.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
statement => "SELECT * from master"
}
}
after executing
bin/logstash -f bin/logstash-example.conf
No error, but logstash not getting started. Output of command:
WARNING: Could not find logstash.yml which is typically located in $LS_HOME/config or /etc/logstash. You can specify the path using --path.settings. Continuing using the defaults
Could not find log4j2 configuration at path /usr/share/logstash/config/log4j2.properties. Using default config which logs errors to the console
root@logstash:/usr/share/logstash#
The jdbc input doesn't keep Logstash alive, i.e. it runs the query once and then Logstash shuts down. It's therefore totally possible that things are working but you're just not seeing the results. Do you have any outputs defined? Do you get more clues if you bump Logstash's loglevel?
Hi,
Thanks for info! redirecting output to elasticsearch and then to Kibana.
I am using database to get logs which are stored in database. I was hoping to keep it live so that an new record with logs can be fetched by logstash. Is there any way to do this?
Yes, there's a built-in schedule feature to run the query at intervals. Use that together with the sql_last_value
parameter to only pick up new or updated rows. See the documentation.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.