# Statsd not work in my logstash

**URL:** <https://discuss.elastic.co/t/statsd-not-work-in-my-logstash/34197>\
**Category:** Logstash\
**Created:** [November 9, 2015, 8:46pm UTC](https://discuss.elastic.co/t/statsd-not-work-in-my-logstash/34197 "2015-11-09T20:46:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chengcheng\_Pei](https://avatars.discourse-cdn.com/v4/letter/c/919ad9/32.png) [@Chengcheng\_Pei](https://discuss.elastic.co/u/Chengcheng_Pei)\
**Post date:** [November 9, 2015, 8:46pm UTC](https://discuss.elastic.co/t/statsd-not-work-in-my-logstash/34197/1 "2015-11-09T20:46:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Chengcheng\_Pei](https://avatars.discourse-cdn.com/v4/letter/c/919ad9/32.png) [@Chengcheng\_Pei](https://discuss.elastic.co/u/Chengcheng_Pei)\
**Post date:** [November 9, 2015, 9:18pm UTC](https://discuss.elastic.co/t/statsd-not-work-in-my-logstash/34197/2 "2015-11-09T21:18:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 5:23am UTC](https://discuss.elastic.co/t/statsd-not-work-in-my-logstash/34197/3 "2017-07-06T05:23:20Z")

</div>


