Logstash can't read stored procedure statement as input

I'm trying to let logstash read from MySQL DB through stored procedure.
Here is my config

input {
jdbc {
jdbc_driver_library => "/home/devops/mysql-connector-java-5.1.49/mysql-connector-java-5.1.49-bin.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://localhost:3306/abc"
jdbc_user => "kilany"
jdbc_password => "kilany"
statement_filepath => "/etc/logstash/conf.d/statement.txt"
}
}

filter {
mutate {
}

}
output {
stdout { codec => "rubydebug" }
}

and here is the statement:

SET @SQL= CONCAT('SELECT * from abc_inb_msg_',DATE_FORMAT(NOW(),'20%y%m%d'));
PREPARE stmt FROM @SQL;
EXECUTE stmt;

But I got the below error

[2020-07-05T18:38:00,601][ERROR][logstash.inputs.jdbc     ][main][b97add3b8c2d316a8513b35000848b54076b07556df746c5357b1f7c5e073835] Java::ComMysqlJdbcExceptionsJdbc4::MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PREPARE stmt FROM @SQL;
EXECUTE stmt' at line 2: SET @SQL= CONCAT('SELECT * from abc_inb_msg_',DATE_FORMAT(NOW(),'20%y%m%d'));
PREPARE stmt FROM @SQL;
EXECUTE stmt;

[2020-07-05T18:38:00,656][WARN ][logstash.inputs.jdbc     ][main][b97add3b8c2d316a8513b35000848b54076b07556df746c5357b1f7c5e073835] Exception when executing JDBC query {:exception=>#<Sequel::DatabaseError: Java::ComMysqlJdbcExceptionsJdbc4::MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PREPARE stmt FROM @SQL;
EXECUTE stmt' at line 2>}

However no syntax error as the statement run successfully on MySQL client.
Any one run logstash to receive from MYSQL DB through stored procedure can help?
Logstash version 7.6

Thanks

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