title: Ruby on Rails: getting Prometheus metrics with Telegraf
body: <p>I have a RoR application with installed <a href="https://github.com/prometheus/client_ruby" rel="nofollow noreferrer">Prometheus-client</a> and <a href="https://github.com/influxdata/telegraf" rel="nofollow noreferrer">Telegraf</a> daemon with <a href="https://gist.github.com/xamenrax/72161788d7289719f7f693de66b28569" rel="nofollow noreferrer">Prometheus input plugin</a> working on the instance I want to monitor.</p>
  
  <p>As far as I understand I need some kind of <a href="https://github.com/prometheus/client_ruby/blob/master/lib/prometheus/middleware/exporter.rb" rel="nofollow noreferrer">exporter middleware</a> to collect metrics from <code>Prometheus::Client.registry</code> and expose them with <code>/metrics</code> HTTP endpoint.</p>
  
  <p>What I don't really understand is how to pass all metrics from different envs (e.g from rake task and app's runtime code) into the same registry (it's an instance variable of <code>Prometheus::Middleware::Exporter.new(registry)</code>)  of the same instance of <code>Prometheus::Middleware::Exporter</code> middleware? </p>
  
  <p>Also, will <code>urls = ["http://localhost:3000/metrics"]</code> config of Prometheus input plugin for Telegraf work on EC2 instance for example?</p>
  
  <p>Thank you for advices.</p>