Skip to content

Commit

Permalink
Merge pull request #166 from hennevogel/feature/adapt-dashboards
Browse files Browse the repository at this point in the history
Adapt sample dashboards to recent changes
  • Loading branch information
hennevogel authored Mar 23, 2021
2 parents e8de56a + e2b3aa9 commit de73969
Show file tree
Hide file tree
Showing 19 changed files with 8,745 additions and 3,884 deletions.
49 changes: 21 additions & 28 deletions sample-dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,42 @@ A dashboard providing Ruby on Rails performance insights based on
[Free Software](https://www.fsf.org/about/what-is-free-software), ready to
run inside your data-center.

![Screenshot of the dashboard](https://grafana.com/api/dashboards/10428/images/6557/image)
![Screenshot of the dashboard](https://grafana.com/api/dashboards/10428/images/10103/image)

By default it measures (in various forms):
By default it measures (in various forms) performance of:

- Controller Action Runtime
- View/Partial Render Runtime
- Database Query Runtime
- Controller Actions
- View/Partial Rendering
- Database Queries
- ActiveJobs
- ActionMailers

It provides an overview and you can also drill down into numbers on a per request basis. Of course you can use all the awesome features that Influx (Downsampling/Data Retention), Grafana (Alerts, Annotations) and influxdb-rails (custom tags) provide and extend this to your needs. Use your freedom and run, copy, distribute, study, change and improve this software!
The dashboards provide an overview and various ways to drill down into numbers on a per request or per action basis. Of course you can use all the awesome features that Influx (Downsampling/Data Retention), Grafana (Alerts, Annotations) and influxdb-rails (custom tags) provide and extend this to your needs. Use your freedom and run, copy, distribute, study, change and improve this software!

## Requirements

To be able to measure performance you need the following things available:
To be able to measure performance of your Ruby on Rails application you need to have the following things available:

- [InfluxDB 1.x](https://docs.influxdata.com/influxdb/v1.8/introduction/install/)
- [Grafana](https://grafana.com/docs/)
- [InfluxDB 1.x](https://www.influxdata.com/products/influxdb/)
- [Grafana](https://grafana.com/)
- A [Ruby On Rails](https://rubyonrails.org/) application with [influxdb-rails](https://github.com/influxdata/influxdb-rails) enabled

## Installation

Once you have influx/grafana instances running in your infrastructure just [import both
dashboards from grafana](https://grafana.com/docs/reference/export_import/#importing-a-dashboard).
Once you have influx/grafana instances running in your infrastructure just [import the
dashboards from grafana.com](https://grafana.com/docs/reference/export_import/#importing-a-dashboard).

- [Overview Dashboard](https://grafana.com/dashboards/10428)
- [Request Dashboard](https://grafana.com/dashboards/10429)
- [Ruby On Rails Performance Overview](https://grafana.com/dashboards/10428/)
- Performance insights into individual requests, see [Ruby On Rails Performance per Request](https://grafana.com/dashboards/10429/)
- Performance of individual actions, see [Ruby On Rails Performance per Action](https://grafana.com/grafana/dashboards/11031)
- [Ruby On Rails Health Overview](https://grafana.com/grafana/dashboards/14115)
- [Ruby on Rails ActiveJob Overview](https://grafana.com/grafana/dashboards/14116)
- [Ruby on Rails Slowlog by Request](https://grafana.com/grafana/dashboards/14118)
- [Ruby on Rails Slowlog by Action](https://grafana.com/grafana/dashboards/14117)
- [Ruby on Rails Slowlog by SQL](https://grafana.com/grafana/dashboards/14119)

You can also paste the `.json` files from this repository.

In the unlikely case that you need to change the dashboard *UID*s during import you can configure the *UID* the `Overview` dashboard uses to link to the `Request` dashboard in the [variables](https://grafana.com/docs/reference/templating/#adding-a-variable). Just paste whatever *UID* you've set up for the `Request` dashboard.

## Demo

This repository includes a [docker-compose](https://docs.docker.com/compose/) demo setup that brings a simple rails app, influxdb and grafana.
Expand All @@ -54,19 +60,6 @@ Go to http://0.0.0.0:4000 and do some things. Every request to the rails app wil

You can also use the dashboard with any other rails app you already have. Follow our [install instructions](https://github.com/influxdata/influxdb-rails/#installation), the default configuration works with the demo InfluxDB running on localhost:8086.

To be able to view individual requests you have to enable request ID tags in your application. Something like:

```ruby
class ApplicationController < ActionController::Base

before_action :set_influx_data

def set_influx_data
InfluxDB::Rails.current.values = { request: request.request_id }
end
end
```

### ...then see the dashboards in action

Just go to http://0.0.0.0:3000 and log in with admin/admin.
Expand Down
11 changes: 8 additions & 3 deletions sample-dashboard/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ task default: %w[prepare]

# rubocop:disable Layout/LineLength
task :prepare do
sh "cat 'Ruby On Rails Performance.json' | sed 's/${DS_INFLUXDB}/InfluxDB/g' > provisioning/performance.json"
sh "cat 'Ruby On Rails Performance (per Request).json' | sed 's/${DS_INFLUXDB}/InfluxDB/g' > provisioning/performance-request.json"
sh "cat 'Ruby On Rails Performance (per Action).json' | sed 's/${DS_INFLUXDB}/InfluxDB/g' > provisioning/performance-action.json"
sh "cat 'Ruby On Rails Performance.json' | sed 's/${DS_INFLUXDB-RAILS}/InfluxDB/g' > provisioning/performance.json"
sh "cat 'Ruby On Rails Performance per Request.json' | sed 's/${DS_INFLUXDB-RAILS}/InfluxDB/g' > provisioning/performance-request.json"
sh "cat 'Ruby On Rails Performance per Action.json' | sed 's/${DS_INFLUXDB-RAILS}/InfluxDB/g' > provisioning/performance-action.json"
sh "cat 'Ruby On Rails ActiveJob.json' | sed 's/${DS_INFLUXDB-RAILS}/InfluxDB/g' > provisioning/activejob.json"
sh "cat 'Ruby On Rails Requests.json' | sed 's/${DS_INFLUXDB-RAILS}/InfluxDB/g' > provisioning/requests.json"
sh "cat 'Ruby On Rails Slowlog by Action.json' | sed 's/${DS_INFLUXDB-RAILS}/InfluxDB/g' > provisioning/slowlog-action.json"
sh "cat 'Ruby On Rails Slowlog by Request.json' | sed 's/${DS_INFLUXDB-RAILS}/InfluxDB/g' > provisioning/slowlog-requests.json"
sh "cat 'Ruby On Rails Slowlog by SQL.json' | sed 's/${DS_INFLUXDB-RAILS}/InfluxDB/g' > provisioning/slowlog-sql.json"
end
# rubocop:enable Layout/LineLength
Loading

0 comments on commit de73969

Please sign in to comment.