我正在使用 Logstash 收集 Twitter 和 Instagram 数据,我想将其保存到 Elasticsearch、MongoDB 和 MySQL。 Logstash 输出插件可用于 Elasticsearch 和 MongoDB,但不适用于 MySQL(需要将此数据保存到多个数据库)。 有什么解决方法吗? 谢谢!
最佳答案
您应该为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"]
}
}
关于mysql - 用于 JDBC/mySQL 的 Logstash 输出插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38967373/