How can I run two sql queries and merge the info into one single document?
I'm trying to use the jdbc input plugin to make a data merge into one document, the data comes from two diferent databases.
In one database I have a table like this:
ID Field1 Field2
1 data1 data2
2 data6 data7
And on the other database i have
ID Field3 Field4
1 data3 data4
2 data8 data9
I want to create a documents like:
{
"id" : "1",
"Field1" : "data1",
"Field2" : "data2",
"Field3" : "data3",
"Field4" : "data4"
},
{
"id" : "2",
"Field1" : "data6",
"Field2" : "data7",
"Field3" : "data8",
"Field4" : "data9"
}
using a conf file like this:
input {
jdbc {
...
statement => "SELECT ID, Field1, Field2 from tableDb1"
}
jdbc {
...
statement => "SELECT ID, Field3, Field4 from tableDb2"
}
}
output {
elasticsearch {
index => "myIndex"
document_type => "myDocument"
document_id => %{id}
hosts => "localhost"
}
}
the document are created like
{
"id" : "1",
"Field1" : "data1",
"Field2" : "data2"
},
{
"id" : "2",
"Field3" : "data8",
"Field4" : "data9"
}
or vice-versa.
But if I run 2 separate instances of logstash, the documents will be complemented.
is it possible to do this in one conf file only.
I'm very new to ELK stack.
Thanks for any help in advance.