Logstash jdbc multi input


#1

Hi
I am currently using logstash-plugin-jdbc to pull data from mysql to elasticsearch.I want to know how can I input multi table from mysql into same index? here is some of the code

input {

    jdbc {
    # the control statement
	statement => select  *  from table1,table2	
}

}
output {

stdout{
    codec => rubydebug
    }

elasticsearch {
	hosts => "myhost"
	index => "test"
	document_id => "%{id}"
}

}


(Magnus Bäck) #2

I want to know how can I input multi table from mysql into same index?

What does that mean? Do you want to join data from multiple tables or do you want to index rows for different tables separately and independently from each other?

  statement => select  *  from table1,table2	

First of all you need to quote the query, and secondly I'm pretty sure you don't want a cross join query like above.


#3

What does that mean? Do you want to join data from multiple tables or do you want to index rows for different tables separately and independently from each other?

I mean I want to join data from two table into one index.

which mean I want let table1 and table2 insert into the index "test".

I changed to use

# the control statement
statement_filepath => "/root/sql/product.sql

inside the product.sql is

select * from table1, table2

but I want to know do you mean I should write

statement => select  *  from table1,table2

as

statement => "select  *  from table1,table2"

(Magnus Bäck) #4

You can use statement_filepath, but if you specify the SQL statement in your config file you need to double quote the string as in your last example.


(system) #5

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