Skip to content
eric edited this page Mar 6, 2012 · 2 revisions

Reporters

Reporters take a Registry and report the metrics to a remote store.

Most reporters take an options hash that can override default behavior:

  • :registry: What registry to report on. Defaults to Metriks::Registry.default
  • :interval: What interval to report on. Defaults to 60 seconds
  • :on_error: A Proc to call when an exception is encountered

Metriks::Reporter::Graphite

Sends metrics to graphite on a set interval.

Takes two arguments:

  • host: hostname of system running the carbon agent
  • port: port that the carbon agent is listening on

Extra arguments in options hash:

  • :prefix: prefix to prepend to all metric keys

Example usage:

reporter = Metriks::Reporter::Graphite.new('localhost', 3309)
reporter.start

Metriks::Reporter::LibratoMetrics

Send metrics to Librato Metrics on a specified interval.

Takes two arguments:

  • email: email address to authenticate against
  • token: API token associated with the email address

Extra arguments in options hash:

  • :prefix: prefix to prepend to all metric keys
  • :source: source to send with all reported metrics

Example usage:

reporter = Metriks::Reporter::LibratoMetrics.new('user@metriks.local', '186dbe1cf215')
reporter.start

Metriks::Reporter::Logger

Sends metrics to a logger on a specified interval.

Extra arguments in options hash:

  • :logger: logger to send metrics to. Defaults to ::Logger.new(STDOUT)
  • :log_level: log level to send to. Defaults to ::Logger::INFO
  • :prefix: prefix to prepend to all log lines. Defaults to metriks:

Example usage:

logger = Logger.new('log/metrics.log')
reporter = Metriks::Reporter::Logger.new(:logger => logger)
reporter.start

Metriks::Reporter::ProcTitle

Being inspired by rack-statsd I realized there are many metrics that are deep in my processes that would be very interesting to keep track of how my workers are running.

This reporter isn't really like the others. It reports metrics by updating your proctitle so you can see select metrics when you run ps aux.

Because space in the process title is limited, it requires configuration to specify what metrics are reported.

Extra arguments in options hash for the initializer:

  • :prefix: prefix to prepend to the process name. Defaults to $0
  • :rounding: number of decimal places the values are rounded to. Defaults to 1

Example usage:

reporter = Metriks::Reporter::ProcTitle.new
reporter.add 'reqs', 'sec' do
  Metriks.meter('rack.requests').one_minute_rate
end
reporter.start

It would allow you to see the metric when you run ps aux:

501      17015 26.0  1.9 416976 246956 ?       Ss   18:54  11:43 thin reqs: 273.3/sec