0

我有一个表,例如 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"
}

但我希望查询值,即“select * from customertable cust where cust.isdeleted !=0”作为 JDBC 输入执行到 logstash

4

1 回答 1

0

jdbc 输入不会为您执行这种间接操作。您可以编写一个存储过程来获取并执行 SQL 并从 jdbc 输入中调用它。

于 2019-07-18T13:37:14.297 回答