Evil::Metrics::Prometheus
Adapter for easy exporting your collected evil metrics from your application to the Prometheus!
One more? Why not X?
- https://github.com/discourse/prometheus_exporter – built on assumption that various processes (web, jobs, etc) are able to communicate between them on single machine. But in containerized environments all your processes on different “machines”!
- https://github.com/getqujing/prome – actually inspired this all these gems but seems abandoned and lacks extensibility.
Installation
Add this line to your application's Gemfile:
gem 'evil-metrics'
# Then add monitoring system adapter, e.g.:
# gem 'evil-metrics-prometheus'
And then execute:
$ bundle
Usage
Exporting from running web servers:
Place following in your
config.rubefore running your application:use Evil::Metrics::Prometheus::ExporterMetrics will be available on
/metricspath.Run web-server from long-running processes (delayed jobs, …):
Evil::Metrics::Prometheus::Exporter.start_metrics_server!WEBrick will be launched in separate thread and will serve metrics on
/metricspath.See evil-metrics-sidekiq for example.
Listening address is configured via
PROMETHEUS_EXPORTER_BINDenv variable (default is0.0.0.0).Port is configured by
PROMETHEUS_EXPORTER_PORTorPORTvariables (default is9310).Use push gateway for short living things (rake tasks, cron jobs, …):
Evil::Metrics::Prometheus.push_gateway.add(Evil::Metrics::Prometheus.registry)Address of push gateway is configured with
PROMETHEUS_PUSH_GATEWAYenv variable.
Development
After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/evil-metrics/evil-metrics-prometheus.
License
The gem is available as open source under the terms of the MIT License.