# Properly Setup Metricbeat with Statsd

**URL:** <https://discuss.elastic.co/t/properly-setup-metricbeat-with-statsd/251792>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [October 12, 2020, 4:04pm UTC](https://discuss.elastic.co/t/properly-setup-metricbeat-with-statsd/251792 "2020-10-12T16:04:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![traw1234](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/traw1234/32/77094_2.png) [@traw1234](https://discuss.elastic.co/u/traw1234)\
**Post date:** [October 12, 2020, 4:04pm UTC](https://discuss.elastic.co/t/properly-setup-metricbeat-with-statsd/251792/1 "2020-10-12T16:04:56Z")

</div>

I'm using Metricbeat to send to a 3rd party logstash, and it's working well with `system` but there seems to be some trouble with `statsd` (running on `localhost:8125`). My current `metricbeat.yml` looks like this (with some other logstash params):

```auto
metricbeat.config.modules:
  # Glob pattern for configuration loading
  path: ${path.config}/modules.d/*.yml

  # Set to true to enable config reloading
  reload.enabled: false

metricbeat.modules:
- module: statsd
  host: localhost
  port: 8125
  metricsets: 
    - server
  enabled: true

# ======================= Elasticsearch template setting =======================

setup.template.settings:
  index.number_of_shards: 1
  index.codec: best_compression
  #_source.enabled: false

```

Now, I do `./metricbeat modules enable statsd` and then `./metricbeat -e` to watch it run. I get this:

```auto
2020-10-12T11:59:43.447-0400	DEBUG	[module]	module/wrapper.go:181	statsd/server will start after 3.081425219s
2020-10-12T11:59:43.447-0400	DEBUG	[cfgfile]	cfgfile/cfgfile.go:193	Load config from file: /Users/xxx/code/metricbeat-7.9.2-darwin-x86_64/modules.d/statsd.yml
2020-10-12T11:59:43.448-0400	DEBUG	[cfgfile]	cfgfile/reload.go:146	Number of module configs found: 1
2020-10-12T11:59:43.449-0400	INFO	cfgfile/reload.go:164	Config reloader started
2020-10-12T11:59:43.449-0400	DEBUG	[cfgfile]	cfgfile/reload.go:194	Scan for new config files
2020-10-12T11:59:43.449-0400	DEBUG	[cfgfile]	cfgfile/cfgfile.go:193	Load config from file: /Users/xxx/code/metricbeat-7.9.2-darwin-x86_64/modules.d/statsd.yml

```

But as soon as I view `/Users/xxx/code/metricbeat-7.9.2-darwin-x86_64/modules.d/statsd.yml`, it says its disabled!:

```auto
- module: statsd
  host: "localhost"
  port: "8125"
  enabled: false

```

I finally edited the `statsd.yml`, setup again, and ran it again, but still to no avail. No metrics are coming in from statsd (though `statsd` is most definitely tracking them). For what it's worth, I also did get this one error (though it seems to have disappeared now):

```auto
2020-10-12T11:43:08.892-0400	ERROR	runtime/panic.go:212	recovered from panic while fetching 'statsd/server' for host ''. Recovering, but please report this.	

{"panic": "runtime error: invalid memory address or nil pointer dereference", "stack": "github.com/elastic/beats/v7/libbeat/logp.Recover\n\t/go/src/github.com/elastic/beats/libbeat/logp/global.go:101\nruntime.gopanic\n\t/usr/local/go/src/runtime/panic.go:969\nruntime.panicmem\n\t/usr/local/go/src/runtime/panic.go:212\nruntime.sigpanic\n\t/usr/local/go/src/runtime/signal_unix.go:695\ngithub.com/elastic/beats/v7/metricbeat/helper/server/udp.(*UdpServer).Stop\n\t/go/src/github.com/elastic/beats/metricbeat/helper/server/udp/udp.go:122\ngithub.com/elastic/beats/v7/x-pack/metricbeat/module/statsd/server.(*MetricSet).Run\n\t/go/src/github.com/elastic/beats/x-pack/metricbeat/module/statsd/server/server.go:102\ngithub.com/elastic/beats/v7/metricbeat/mb/module.(*metricSetWrapper).run\n\t/go/src/github.com/elastic/beats/metricbeat/mb/module/wrapper.go:203\ngithub.com/elastic/beats/v7/metricbeat/mb/module.(*Wrapper).Start.func1\n\t/go/src/github.com/elastic/beats/metricbeat/mb/module/wrapper.go:147"}

```

I have a few questions on Metricbeat with statsd:

- what is the difference between `modules.d/statsd.yml` and `metricbeat.modules` in `metricbeat.yml`, and do I have to set both up?
- is there anything on the `statsd` side that I have to do to make it compatible with Metricbeat, beyond matching the IP and port?
- are there any simple examples of Metricbeat actually working with statsd? I can't seem to find a single one online

---

<div class="post-metadata">

**Author:** ![mtojek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mtojek/32/63863_2.png) [@mtojek](https://discuss.elastic.co/u/mtojek)\
**Post date:** [October 13, 2020, 6:17am UTC](https://discuss.elastic.co/t/properly-setup-metricbeat-with-statsd/251792/2 "2020-10-13T06:17:26Z")

</div>

> [@traw1234](#):
>
> - what is the difference between `modules.d/statsd.yml` and `metricbeat.modules` in `metricbeat.yml` , and do I have to set both up?
> - is there anything on the `statsd` side that I have to do to make it compatible with Metricbeat, beyond matching the IP and port?
> - are there any simple examples of Metricbeat actually working with statsd? I can't seem to find a single one online

1. You're good to go with setting up only files in `modules.d`.
2. I don't thing so, it's not a complex integration. Did you try to enable the debug mode?
3. This is relatively simple integration, there is no more configuration than: [Statsd module | Metricbeat Reference [8.11] | Elastic](https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-module-statsd.html)

For the panic, I opened a Beats issue: [[Metricbeat][statsd] runtime error: invalid memory address or nil pointer dereference · Issue #21733 · elastic/beats · GitHub](https://github.com/elastic/beats/issues/21733)

---

<div class="post-metadata">

**Author:** ![traw1234](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/traw1234/32/77094_2.png) [@traw1234](https://discuss.elastic.co/u/traw1234)\
**Post date:** [October 13, 2020, 1:46pm UTC](https://discuss.elastic.co/t/properly-setup-metricbeat-with-statsd/251792/3 "2020-10-13T13:46:35Z")

</div>

Awesome thats very helpful, answers all of my questions.

Thanks for creating the issue, it keeps surfacing so I have a feeling thats whats making this not work.

---

<div class="post-metadata">

**Author:** ![traw1234](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/traw1234/32/77094_2.png) [@traw1234](https://discuss.elastic.co/u/traw1234)\
**Post date:** [October 13, 2020, 2:08pm UTC](https://discuss.elastic.co/t/properly-setup-metricbeat-with-statsd/251792/4 "2020-10-13T14:08:06Z")

</div>

For what it's worth, I just got it working (I didn't realize Metricbeat is already running a Statsd service). The issue was just that I was defining the statsd config twice, once in `metricbeat.config.modules` and once in `metricbeat.modules`. I deleted `metricbeat.config.modules` and its working perfectly now.

---

<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:** [November 10, 2020, 4:08pm UTC](https://discuss.elastic.co/t/properly-setup-metricbeat-with-statsd/251792/5 "2020-11-10T16:08:13Z")

</div>

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