Open gbp opened 6 years ago
Seems a better option is the prometheus_exporter
gem.
https://samsaffron.com/archive/2018/02/02/instrumenting-rails-with-prometheus
Done some initial work on this here: https://github.com/mysociety/foi-for-councils/compare/prometheus-metrics
Running vagrant up
should install and configure prometheus
so it knows about the Rails app and to start automatically on boot.
Then after starting the rails server
and prometheus_exporter
using foreman (vagrant ssh
then bundle exec foreman start -p 3000
) everything else required should be running.
Rails will be accessible at http://0.0.0.0:3000/ Prometheus will be accessible at http://0.0.0.0:9090/
Looks cool, I'll spin this up and have a look.
This looks pretty good! We'll need to be able to configure the port for the collector in the final app in case we need to run multiple collectors for different services on the same host, but that's simple enough.
We'll need to consider labels, too. I'll have a bit of a think about this but my first thought in production would be to use the vhost name as the job, we can then aggregate multiple instances this way but also slice them on instance if needed (in production, instance will be fqdn:port, not localhost:port). None of this is needed for testing, of course.
I've got a couple of minor changes to suggest for the bootstrapping process, one general one for the Vagrantfile
which I'll make separately and another change to the provisioning script to use systemctl
- I'll add this as a commit to this branch.
@sagepe has suggested integrating with an Prometheus server which can collect basic application metrics from an
/metrics
endpoint.Their Ruby client gem [1] provides middleware to do just this.
[1] https://github.com/prometheus/client_ruby