2016-08-16 71 views
0

我使用Logstash收集Twitter和Instagram數據,並且我想將它保存到Elasticsearch,MongoDB和MySQL。 Logstash輸出插件可用於Elasticsearch和MongoDB,但不適用於MySQL(需要將此數據保存到多個數據庫)。 任何解決方法? 謝謝!用於JDBC/mySQL的Logstash輸出插件

+1

這個插件應該有所幫助:https://github.com/theangryangel/logstash-output-jdbc – Val

回答

0

您應該爲logstash安裝插件ouput-jdbc。從https://github.com/theangryangel/logstash-output-jdbc/tree/master下載和構建,安裝

然後你就可以這樣使用:

input { 
    stdin{} 
} 

filter{ 
    json{ 
     source => "message" 
    } 
} 

output { 
    stdout{ 
     codec=>rubydebug{} 
    } 
    jdbc { 
    connection_string => "jdbc:mysql://192.168.119.202:3306/outMysql?user=root&password=root" 
     statement => ["INSERT INTO user(userName,ip) values(?,?)","userName","ip"] 
    } 
}