您好,当尝试使用logstash与多个JDBC输入创建索引时,无法在linux环境..but中创建索引,它在Windows上工作。在windows系统类型的Cento-os索引上创建的索引正在创建,如下所示%{ ....but }
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"
}
}发布于 2019-07-16 18:38:06
找到了这个问题的解决方案,可以通过替换类型标签来添加标签“table1”#将每个jdbc输入中的类型替换为标签。
为输出添加以下代码
output {
if "table1" in [tags] {
elasticsearch {
index => "ABC"
hosts => "localhost:9200"
} }
if "table2" in [tags] {
elasticsearch {
index => "CBA"
hosts => "localhost:9200"
} }
}https://stackoverflow.com/questions/57041730
复制相似问题