Statsd not work in my logstash


(Chengcheng Pei) #1

The config file:

# input are the kafka messages
input
{
    kafka
    {
        topic_id => 'test2'
    }
}

# Try to match sensor info
filter
{
    json { source => "message"}
}

# StatsD and stdout output
output
{
    stdout
    {
        codec => line
        {
            format => "%{[testmessage][0][key]}"
        }
    }

    stdout { codec=>rubydebug }
    
    statsd
    {
        host => "localhost"
        port => 8125
        increment => ["test.%{[testmessage][0][key]}"]
    }
}

Input kafka message:
{"testmessage":[{"key":"key-1234"}]}

Output:

key-1234
{
    "testmessage" => [
        [0] {
            "key" => "key-1234"
        }
    ],
       "@version" => "1",
     "@timestamp" => "2015-11-09T20:11:52.374Z"
}

Log:

{:timestamp=>"2015-11-09T20:29:03.562000+0000", :message=>"Done running kafka input", :level=>:info}
{:timestamp=>"2015-11-09T20:29:03.563000+0000", :message=>"Plugin is finished", :plugin=><LogStash::Outputs::Stdout codec=><LogStash::Codecs::Line format=>"%{[testmessage][0][key]}", charset=>"UTF-8">, workers=>1>, :level=>:info}
{:timestamp=>"2015-11-09T20:29:03.564000+0000", :message=>"Plugin is finished", :plugin=><LogStash::Outputs::Statsd increment=>["test1.test", "test.%{[testmessage][0][key]}"], codec=><LogStash::Codecs::Plain charset=>"UTF-8">, workers=>1, host=>"localhost", port=>8125, namespace=>"logstash", sender=>"%{host}", sample_rate=>1, debug=>false>, :level=>:info}
{:timestamp=>"2015-11-09T20:29:03.564000+0000", :message=>"Pipeline shutdown complete.", :level=>:info}

Very wired why statsd does not work in my logstash. Looking into lots of examples by Google, no idea why. Any suggestions are welcome. Thanks.


(Chengcheng Pei) #2

I found the reason, logstash-output-statsd is using UDP by default. But my statsd server is set to use TCP.


(system) #3