rails, influxdb, grafana, apm,

Setting up Rails Performance dashboard with influxdb and grafana

Swapnil Gourshete Swapnil Gourshete Follow May 02, 2020 · 2 mins read
Setting up Rails Performance dashboard with influxdb and grafana
Share this

When application gets stable at some point, we try to improve things we built for a while now. And improving performance tops the list for me. Application performance is a large concept which can be measured with different number of parameters. It also depends on underlying infrastructure.

So here we will setup very simple and minimalistic performance dashboard for a Rails application which will help us monitor controller action runtime, database query runtime and view rendering runtime. Let’s start


  1. influxdb: install unless is_influxdb_installed?
  2. grafana: install unless is_grafana_installed?
  3. Rails app

  • Now add gem influxdb-rails gem to Rails application Gemfile and run bundle. To get things up run
    bundle exec rails generate influxdb

    This will create initialzer config/initializers/influxdb_rails.rb, which allows configuration of this gem.

  • We need one infuxdb database to store performance time series data, which eventually will be used by grafana dashboard. Open influxdb cosnole by running influx. If you face issue of connection refused, make sure influxd is running. Once console is accessible create a database. I’m creating database named ‘rails-dev’ for now.

  • We need to tell our rails application what database it should look for to store data. If it is going to use database service from another instance, we must provide hostname. For all this, open influxdb initializer file.

For database name -

 config.client.database = "rails-dev"

If you are going to use a hosted influxdb instance then provide its address here

For hostname -

 config.client.hosts = ["host-name.com/8086"]

At this point we are set with storing performance metrics data into influxdb ‘rails-dev’.

  • Check if grafana installed is working. Open http://localhost:3005. Recheck if port number is appropriate. You can verify port number and other details of grafana from ‘grafana.ini’

  • Let’s import a simple dashboard in grafana. We will use already created dashboard for the rails app. Navigate to import screen & paste this board id 10428. Grafana will update configuration and import the board. That’s it. Import is pretty simple and straight forward.

Now we are all prepared to see live performance metrics of our application. After some requests grafana dashboard will look something like

Thanks for reading.

References -

Swapnil Gourshete
Written by Swapnil Gourshete Follow
Hi I am Swapnil, a Software Engineer and computer science enthusiastic