我有logstash.conf
文件,我从MySQL数据库中获取数据。但现在我必须从Elasticsearch获取数据并将其放入Graphite中。有一个我的logstash.conf
的代码:
input {
jdbc {
type => "some type"
jdbc_driver_library => "sqljdbc42.jar"
jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
jdbc_connection_string => "jdbc:sqlserver://host:port;databaseName=db name"
jdbc_user => "username"
jdbc_password => "***"
jdbc_default_timezone => "Asia/Almaty"
statement_filepath => "sqlscript.sql"
schedule => "*/30 * * * *"
}
}
output {
stdout { codec => json }
if [type] == "some type" {
graphite {
host => "some host"
port => port
metrics => [some.metric", "%{cnt}"]
}
}
}
您需要做的就是将logstash.conf中的输入配置更改为:
elasticsearch {
hosts => "localhost"
query => '{ "query": { "match_all": {} }, "sort": [ "_doc" ] }'
}