我有一个表,例如QueryConfigTable,它在一个列中保存一个查询,例如,从customertable中选择*。我希望该列中的查询成为保存查询,并以logstash I的形式作为JDBC的输入执行
将列查询作为值并存储到elasticSearch
input {
jdbc {
jdbc_driver_library => "mysql-connector-java-5.1.36-bin.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://localhost:3306/MYDB"
//MYDB will be set dynamically.
jdbc_user => "mysql"
parameters => { "favorite_artist" => "Beethoven" }
schedule => "* * * * *"
statement => "SELECT * from QueryConfigTable "
}
}
/// output as elasticSearch
elasticsearch {
hosts => ["http://my-host.com:9200"]
index => "test"
}
final output is
"_index": "test",
"_type": "doc",
"_source": {
"product": "PL SALARIED AND SELF EMPLOYED",
"@version": "1",
"query": "select * from customertable cust where cust.isdeleted !=0"
}
但是我希望查询值,即“从customertable cust中选择*,其中cust.isdeleted!= 0”将作为对logstash的JDBC输入执行
答案 0 :(得分:0)
jdbc输入不会为您执行这种间接调用。您可以编写一个存储过程来获取并执行SQL,然后从jdbc输入中调用它。