influxdb-rails

Build Status

Auotmatically instrument your Ruby on Rails applications and write the metrics directly into InfluxDB.

Install

$ [sudo] gem install influxdb-rails

Or add it to your Gemfile, etc.

Usage

To get things set up, just create an initializer:

$ rails g influxdb

Then, you can edit the file at config/initializers/influxdb-rails.rb. The default config should look something like this:

InfluxDB::Rails.configure do |config|
  config.influxdb_database = "rails"
  config.influxdb_username = "root"
  config.influxdb_password = "root"
  config.influxdb_hosts    = ["localhost"]
  config.influxdb_port     = 8086

  # config.series_name_for_controller_runtimes = "rails.controller"
  # config.series_name_for_view_runtimes       = "rails.view"
  # config.series_name_for_db_runtimes         = "rails.db"
end

Out of the box, you'll automatically get reporting of your controller, view, and db runtimes for each request. You can also call through to the underlying InfluxDB::Client object to write arbitray data like this:

InfluxDB::Rails.client.write_point("events", {url: "/foo", user_id: current_user.id})

Additional documentation for InfluxDB::Client lives in the influxdb-ruby repo.