如何使用Logstash从Elasticsearch获取数据并将其放入Graphite?

时间:2019-02-25 07:38:49

标签: elasticsearch logstash graphite

我有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}"]
     }

    }
}

1 个答案:

答案 0 :(得分:0)

您需要做的就是将logstash.conf中的输入配置更改为:

elasticsearch {
  hosts => "localhost"
  query => '{ "query": { "match_all": {} }, "sort": [ "_doc" ] }'
}

Just use elasticsearch input for logstash