hi,同时尝试使用Logstash和多个JDBC创建索引 输入,无法在linux环境中创建索引。 在Windows上。在Windows系统上创建的索引....但是在Cento-os上,索引创建如下%{type}
input {
jdbc {
jdbc_driver_library => "/Users/logstash/mysql-connector-java-5.1.39-bin.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://localhost:3306/database_name"
jdbc_user => "root"
jdbc_password => "password"
schedule => "* * * * *"
statement => "select * from table1"
type => "table1"
}
jdbc {
jdbc_driver_library => "/Users/logstash/mysql-connector-java-5.1.39-bin.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://localhost:3306/database_name"
jdbc_user => "root"
jdbc_password => "password"
schedule => "* * * * *"
statement => "select * from table2"
type => "table2"
}
# add more jdbc inputs to suit your needs
}
output {
elasticsearch {
index => "%{type}"
hosts => "localhost:9200"
}
}
答案 0 :(得分:0)
找到解决方案,可以通过替换类型添加标签 tags =>“ table1”#在每个jdbc的输入中用标签替换类型
添加以下代码进行输出
output {
if "table1" in [tags] {
elasticsearch {
index => "ABC"
hosts => "localhost:9200"
} }
if "table2" in [tags] {
elasticsearch {
index => "CBA"
hosts => "localhost:9200"
} }
}