运维技术交流,查看http-header

mysql写入es

mysql写入es

通过 logstash可以直接将股票数据导入到es 方便生成图表分析

配置mysql导入到es

input {
  jdbc {
    jdbc_driver_library => "/tmp/mysql-connector-java-5.1.42.jar"
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://192.168.71.2:3306/young"
    jdbc_user => "root"
    jdbc_password => "yuan"
    statement => "SELECT * from stock_basic"
  }
}

filter {

    mutate { convert => {"lat" => "float"} }
    mutate { convert => {"long" => "float"} }
    mutate { rename => {"lat" => "[location][lat]"} }
    mutate { rename => {"long" => "[location][lon]"} }

    date {
        locale => "eng"
        match => ["datetime", "yyyy-MM-dd HH:mm:ss", "ISO8601"]
        target => "datetime"
           } 

}

output{
   elasticsearch {
   hosts => ["elasticsearch:9200"] 
   index => "stock_basic"
   user => "elastic"
   password => "changeme"

}
  stdout { codec => rubydebug { metadata => true } }
   # stdout { codec => dots }
}