Configure JDBC input with SSL connection for MySQL

(Devang Gaglani) #1

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?

(Magnus Bäck) #2

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.

(Devang Gaglani) #3

I tired this in config file:
jdbc {
jdbc_connection_string => "jdbc:mysql://"
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/ Using default config which logs errors to the console

(Magnus Bäck) #4

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?

(Devang Gaglani) #5

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?

(Magnus Bäck) #6

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.

(system) #7

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