Menu
Grafana Cloud

Ruby Rack integration for Grafana Cloud

The Rack webserver interface for Ruby allows easily building web applications. This integration enables the agent to send metrics to Grafana Cloud along with a useful default dashboard for visualization.

Use the walkthrough in Grafana Cloud to install the Ruby Rack integration.

This integration monitors a Rack web application (e.g. any Sinatra or Rails application) using the Collector middleware included in the Ruby Prometheus client library.

To get started, add the Prometheus client library to your Gemfile:

gem 'prometheus-client'

Then change the config.ru file of your Rack application to use the Prometheus Collector and Exporter middlewares before running your app:

require 'prometheus/middleware/collector'
require 'prometheus/middleware/exporter'

use Prometheus::Middleware::Collector
use Prometheus::Middleware::Exporter

run Sinatra::Application

You can refer to this example Sinatra app for a complete setup of the Prometheus client library.

Post-install configuration for the Ruby Rack integration

In the agent configuration file, the agent must be pointed to the Ruby process, such as ruby:9292 in the example below, that exposes a /metrics endpoint.

metrics:
  wal_directory: /tmp/wal
  global:
    scrape_interval: 5s
  configs:
    - name: integrations
      scrape_configs:
        - job_name: integrations/ruby-rack
          static_configs:
            - targets: ['ruby:9292']
      remote_write:
        - url: http://cortex:9009/api/prom/push