motiv-labs / janus

An API Gateway written in Go
https://hellofresh.gitbooks.io/janus
MIT License
2.78k stars 318 forks source link

StatsD Configuration #359

Closed cchatfield closed 4 years ago

cchatfield commented 5 years ago

Unable to get statsd to connect to a statsd hosts. The container is run and is pointed to a service running on the docker host.

Using the stats configuration I have tried the following to no avail:

ENV - STATS_DSN = "statsd://${NOMAD_IP_web}:8125" STATS_PREFIX = "janus"


{"error":"could not initialize statsd client: address statsd://192.168.121.32:8125: too many colons in address","event_name":"startup","level":"warning","msg":"an error occurred when an event was triggered","time":"2018-09-18T21:08:37Z"}

This ignores the IP. ENV - STATS_DSN = "statsd:${NOMAD_IP_web}:8125" STATS_PREFIX = "janus"

[StatsGo] 2018/09/18 21:12:42 Trying to connect to statsd instance  addr=   prefix=
[StatsGo] 2018/09/18 21:12:42 An error occurred while connecting to StatsD  addr=   prefix= error=write udp 127.0.0.1:44623->127.0.0.1:8125: write: connection refused
{"error":"write udp 127.0.0.1:44623-\u003e127.0.0.1:8125: write: connection refused","level":"fatal","msg":"Error initializing stats client","time":"2018-09-18T21:12:42Z"}

What is the correct format to specify host and port?

Janus version: latest OS and version: [Enter OS name and version here]

vgarvardt commented 5 years ago

statsd://graphite.hellofresh.io:8125/janus.live where path is statsd prefix

s4nji commented 5 years ago

@cchatfield STATS_PREFIX environment variable is no longer used.

The format @vgarvardt mentioned (statsd://${statsd_host}:8125/${statsd_prefix}) should work.

I am closing the issue; please feel free to reopen the topic if the issue persists.

DineshReddyK commented 5 years ago

Hi, Yes, I am facing the similar issue. Init() seems to be fine as it says "Statsd metrics enabled", but later it fails with "too many colons" error.

janus[8779]: [StatsGo] 2019/02/08 20:30:39 Trying to connect to statsd instance        addr=127.0.0.1:8125        prefix=
janus[8779]: {"level":"debug","metrics_dsn":"statsd://127.0.0.1:8125","msg":"Statsd metrics enabled","plugin":"cb","plugin_event":"startup","time":"2019-02-08T20:30:39+02:00"}
janus[8779]: 2019/02/08 20:30:39 Could not initiale buffered client: address statsd://127.0.0.1:8125: too many colons in address. Falling back to a Noop Statsd client
janus[8779]: {"error":"could not initialize statsd client: address statsd://127.0.0.1:8125: too many colons in address","event_name":"startup","level":"warning","msg":"an error occurred when an event was triggered","time":"2019-02-08T20:30:39+02:00"}

my janus toml config file section of stats looks like this,

[stats]
  exporter = "prometheus"
  dsn = "statsd://127.0.0.1:8125"
vgarvardt commented 5 years ago

Ok, I think I know where the problem could be, reopenning the issue.

DineshReddyK commented 5 years ago

@s4nji @vgarvardt Thanks a lot for the quick resolution. Now the error logs are disapparated and stats are appearing.