David
David

Reputation: 17

Stored Query from Database as JDBC input to Logstash

I have table eg QueryConfigTable that holds a query in one column eg ,select * from customertable .I want the query in the column to be hold query to be executed as input to JDBC in logstash I

its taking the column query as value and storing in to 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"
}

but i want the query value ie, "select * from customertable cust where cust.isdeleted !=0 "to be executed as JDBC input to logstash

Upvotes: 0

Views: 534

Answers (1)

Badger
Badger

Reputation: 4072

The jdbc input will not do this kind of indirection for you. You could write a stored procedure that fetches and executes the SQL and call that from the jdbc input.

Upvotes: 0

Related Questions