0

您好,在尝试使用具有多个 JDBC 输入的 logstash 创建索引时,无法在 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"
    }
}
4

1 回答 1

0

found the solution for this can Add tags by replacing type tags =>"table1" # replace the type with tags in input of every jdbc

add the following code for output

output {
    if "table1" in [tags] {
 elasticsearch {
 index => "ABC"
 hosts => "localhost:9200" 
} } 

if "table2" in [tags] {
 elasticsearch {
 index => "CBA"
 hosts => "localhost:9200" 
} } 
 }
于 2019-07-16T10:38:06.260 回答