I have two different sources. One is the oracle database of our cmdb and the other is the mysql database of ocs inventory. In the first source my document_id is an ciid like this 'CI00001' in the second source my id is a hostname like 'logstash01.domain.tld'
I would like to join these two tables to one big index. I tried this with the following logstash configuration:
input {
jdbc {
jdbc_driver_library => "/usr/share/logstash/bin/mysql-connector-java-8.0.11.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://server:3306/ocsweb"
jdbc_user => "ocsread"
jdbc_password => "secret"
statement => "SELECT hardware.name as hostname, cpu
FROM hardware
INNER JOIN mytable on mytable.HARDWARE_ID = hardware.ID"
type => "ocs_inventory"
}
}
filter {
if [type] == "ocs_inventory" {
elasticsearch {
hosts => ["http://localhost:9200"]
index => "cmdb"
query => "my_host_name:%{hostname}"
}
}
}
output {
if [type] == "ocs_inventory" {
elasticsearch {
hosts => ["http://localhost:9200"]
index => "%{type}_static"
document_id => "%{hostname}"
}
}
}
Example Data:
cmdb:
{
"_index": "cmdb_static",
"_type": "doc",
"_id": "CI00001",
"_version": 4,
"_score": null,
"_source": {
"logical_name": "CI00001",
"my_host_name": "logstash01.domain.tld",
"contact_name": "Fred",
"@version": "1",
"subtype": "Virtual Server",
"type": "cmdb"
},
"fields": {
"@timestamp": [
"2018-07-10T14:37:56.837Z"
],
"sysmodtime": [
"2018-07-10T14:12:08.000Z"
]
}
}
ocs inventory
{
"_index": "ocs_inventory_static",
"_type": "doc",
"_id": "logstash01.domain.tld",
"_version": 13,
"_score": null,
"_source": {
"@timestamp": "2018-07-10T14:00:21.229Z",
"cpu": 4,
"@version": "1",
"type": "ocs_inventory",
"hostname": "logstash01.domain.tld"
},
"fields": {
"@timestamp": [
"2018-07-10T14:00:21.229Z"
]
}
}
Do you have any idea how this isn't working?