Sending stats to StatsD with Elixometer in production environment

I’m having trouble getting Elixometer to work with statsd when statsd is running on a server other than localhost.

Everything works fine when running it locally, but when I have the app running on a different machine than statsd, it doesn’t work. My firewall does allow UDP requests from the app server to port 8125 of the statsd server, so I don’t think it’s a networking problem.

I can successfully update statsd from the app server with a bash command. I can even successfully update statsd from the app console on my server using :os.cmd. It is only when I go through Elixometer/exometer_core/exometer_report_statsd that nothing happens.

Here is the config that works on my local machine:

config :elixometer,
  reporter: :exometer_report_statsd,
  update_frequency: 5_000,
  env: Mix.env,
  metric_prefix: "myapp"

config :exometer_core, report: [
  reporters: [
    exometer_report_statsd: [
      host: "localhost",
      port: 8125
    ]
  ]
]

And here is the config on the app server:

config :elixometer,
  reporter: :exometer_report_statsd,
  update_frequency: 5000,
  env: Mix.env,
  metric_prefix: "hydrogen"

config :exometer_core, report: [
  reporters: [
    exometer_report_statsd: [
      host: "10.0.0.6",
      port: 8125
    ]
  ]
]

I can use the following bash command to update statsd successfully (I run this from the same server as the app):

echo "deploys.test.myservice:1|c" | nc -w 1 -u 10.0.0.6 8125

I know this may not specifically be Elixometer’s fault, but I’m running out of ideas to get this working :smile:

1 Like

Alright, figured it out. I got this configuration from a blog post, but apparently it was a little off. exometer_report_statsd requires the following config:

config :exometer_core, report: [
  reporters: [
    exometer_report_statsd: [
      hostname: 'XXX.XXX.59.255',
      port: 8125
    ]
  ]
]

For anyone coming across this issue, note the hostname key instead of host, and the single quotes instead of double quotes.

3 Likes

Thanks for the follow-up! I was highly curious but had no ideas. :slight_smile:

2 Likes