# Logstash StatsD Plugin caches DNS resolutions when using UDP forever

**URL:** <https://discuss.elastic.co/t/logstash-statsd-plugin-caches-dns-resolutions-when-using-udp-forever/170413>\
**Category:** Logstash\
**Created:** [February 28, 2019, 10:06pm UTC](https://discuss.elastic.co/t/logstash-statsd-plugin-caches-dns-resolutions-when-using-udp-forever/170413 "2019-02-28T22:06:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SpencerMalone](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@SpencerMalone](https://discuss.elastic.co/u/SpencerMalone)\
**Post date:** [February 28, 2019, 10:06pm UTC](https://discuss.elastic.co/t/logstash-statsd-plugin-caches-dns-resolutions-when-using-udp-forever/170413/1 "2019-02-28T22:06:19Z")

</div>

The recent(ish) release of [https://github.com/logstash-plugins/logstash-output-statsd](https://github.com/logstash-plugins/logstash-output-statsd) to 3.2.0 used the latest release of [https://github.com/reinh/statsd/blob/master/lib/statsd.rb](https://github.com/reinh/statsd/blob/master/lib/statsd.rb), which changed the socket logic to reuse a single socket until error ([https://github.com/reinh/statsd/blob/master/lib/statsd.rb#L438](https://github.com/reinh/statsd/blob/master/lib/statsd.rb#L438)). This works fine for TCP, but for UDP if a host name changes (like it might in a k8s-like environment), we will never refresh the socket and start losing stats. I'm sort of assuming the upstream won't get fixed based on the issues that exist in their github (calls for a maintainer, etc.)

I confirmed this by testing [https://github.com/SpencerMalone/logstash-output-statsd/commit/5130f960ae2e45e40b01da7427cf21a8e09cd03c](https://github.com/SpencerMalone/logstash-output-statsd/commit/5130f960ae2e45e40b01da7427cf21a8e09cd03c), but am unsure of how to proceed for an upstream fix. My current solution is hacky at best. I don't really recall ruby's concurrency semantics, is it a whole new process? Can we call connect from a child thread created in the register function? Anyone have opinions on how to best approach this?

---

<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:** [March 28, 2019, 10:19pm UTC](https://discuss.elastic.co/t/logstash-statsd-plugin-caches-dns-resolutions-when-using-udp-forever/170413/2 "2019-03-28T22:19:26Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
