我正在使用Logstash收集Twitter和Instagram的数据,我想把它保存到Elasticsearch、MongoDB和MySQL上。有一些Logstash输出插件可用于Elasticsearch和MongoDB,但不能用于MySQL (需要将此数据保存到多个数据库)。是否有解决此问题的方法?谢谢!
发布于 2017-09-11 04:31:29
您应该为logstash安装plugin ouput jdbc。从https://github.com/theangryangel/logstash-output-jdbc/tree/master下载并构建、install。
然后你可以像这样使用:
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"]
}
}
https://stackoverflow.com/questions/38967373
复制相似问题