My previous post briefly described the setup of system-metric collection. (At least the server-side setup required to receive the metrics submitted by various clients.)
When it came to the clients I was complaining that collectd
was too
heavyweight, as installing it pulled in a ton of packages. A kind
twitter user pointed out that you can get most of the stuff you need
via the use of the of collectd-core
package:
# apt-get install collectd-core
I guess I should have known that! So for the moment that's what I'm using to submit metrics from my hosts. In the future I will spend more time investigating telegraf, and other "modern" solutions.
Still with collectd-core
installed we've got the host-system metrics
pretty well covered. Some other things I've put together also support
metric-submission, so that's good.
I hacked up a quick package for automatically submitting metrics to a remote server, specifically for golang applications. To use it simply add an import to your golang application:
import (
..
_ "github.com/skx/golang-metrics"
..
)
Add the import, and rebuild your application and that's it! Configuration is carried out solely via environmental variables, and the only one you need to specify is the end-point for your metrics host:
$ METRICS=metrics.example.com:2003 ./foo
Now your application will be running as usual and will also be submitting metrics to your central host every 10 seconds or so. Metrics include the number of running goroutines, application-uptime, and memory/cpu stats.
I've added a JSON-file to import as a grafana dashboard, and you can see an example of what it looks like there too: