# Blazer: A Self-Hosted SQL BI Tool for Ruby on Rails Applications

> Blazer is a Ruby on Rails engine that adds a query editor, chart builder, dashboard creator, and data-check alerting system to any Rails app, connecting to the same database the application already uses without requiring a separate analytics service. It was developed at Instacart and is distributed as a gem under the MIT licence.

**ankane/blazer** — Business intelligence made simple

- Repository: https://github.com/ankane/blazer
- Stars: 4,801 · Forks: 501
- Language: Ruby
- License: MIT
- Published: 2026-09-23 · Updated: 2026-09-23 · Language: en
- Canonical page: https://hysenlabs.com/projects/ankane-blazer

## What Blazer Does and Where It Runs

Blazer is a business intelligence engine distributed as a Ruby gem that mounts inside an existing Rails application. Once installed, it provides a web interface for writing and saving SQL queries, visualising the results as charts, combining queries into dashboards, and setting up scheduled data checks that send email or Slack notifications when a condition is met. The README describes it as battle-tested at Instacart, which is a concrete provenance claim: the tool grew out of a production analytics need at a large e-commerce company rather than being designed as a standalone product from scratch. Because Blazer mounts inside an existing Rails app, it inherits the app's authentication and routing setup rather than requiring a separate login system. The README includes instructions for protecting the dashboard with Basic Authentication, Devise, or a custom `before_action` method in the application controller.

## Installation: Adding Blazer to a Rails Application

Add the gem to the application's Gemfile:

```ruby
gem "blazer"
```

Run the generator and database migration:

```sh
rails generate blazer:install
rails db:migrate
```

Mount the engine in `config/routes.rb`:

```ruby
mount Blazer::Engine, at: "blazer"
```

For production, specify the database connection via an environment variable:

```ruby
ENV["BLAZER_DATABASE_URL"] = "postgres://user:password@hostname:5432/database"
```

The README recommends using a read-only database user in production rather than the application's primary credentials. It provides the exact SQL for creating a read-only role in both PostgreSQL and MySQL. For PostgreSQL:

```sql
BEGIN;
CREATE ROLE blazer LOGIN PASSWORD 'secret';
GRANT CONNECT ON DATABASE dbname TO blazer;
GRANT USAGE ON SCHEMA public TO blazer;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO blazer;
ALTER DEFAULT PRIVILEGES FOR ROLE migrations_role IN SCHEMA public GRANT SELECT ON TABLES TO blazer;
COMMIT;
```

Blazer attempts to protect against write queries by running each query in a transaction that rolls back, but a read-only user is the safer approach.

## Variables, Smart Columns, and Linked Columns

Blazer supports query parameters through curly-brace syntax. A query written as `SELECT * FROM users WHERE gender = {gender}` exposes a form field in the interface for the `gender` variable. Time ranges use the special `{start_time}` and `{end_time}` variables, which generate a date-range picker. Smart Variables allow mapping a numeric foreign key to a human-readable label. When a query filters on `occupation_id`, a Smart Variable configured in `config/blazer.yml` can display occupation names instead of IDs:

```yml
smart_variables:
  occupation_id: "SELECT id, name FROM occupations ORDER BY name ASC"
```

Smart Columns apply the same idea to result sets: if a query returns a `city_id` column, a Smart Column can resolve the city name without requiring the query author to add a join. Linked Columns allow result values to become hyperlinks, useful for turning a user_id column into a link to the admin user page:

```yml
linked_columns:
  user_id: "/admin/users/{value}"
```

These three features together mean that analysts can write simpler queries while the interface handles the presentation concerns.

## Data Checks and Alerting

Blazer's check system runs saved queries on a schedule and sends notifications when the results meet a configured condition. The README shows cron syntax for three built-in schedules (every 5 minutes, every hour, every day) and a daily digest of failing checks:

```
*/5 * * * * rake blazer:run_checks SCHEDULE="5 minutes"
0   * * * * rake blazer:run_checks SCHEDULE="1 hour"
30  7 * * * rake blazer:run_checks SCHEDULE="1 day"
0   8 * * * rake blazer:send_failing_checks
```

For applications using Solid Queue, the README provides the equivalent configuration in `config/recurring.yml`. Slack notifications require an incoming webhook URL set in the `BLAZER_SLACK_WEBHOOK_URL` environment variable. The check system is useful for data quality monitoring: a team can write a query that returns rows only when something is wrong, then configure Blazer to alert if that query returns any results. The README requires setting an action mailer host in `config/environments/production.rb` for email-based alerts to work.

## Multiple Data Sources and Additional Capabilities

Blazer connects to PostgreSQL, MySQL, Redshift, and a longer list documented in the README under 'Full list'. Multiple data sources can be configured simultaneously, which allows a single Blazer installation to query different databases from the same interface. Beyond standard queries, Blazer supports cohort analysis, anomaly detection, and forecasting as listed in the README's documentation section. It also supports file uploads, which allows analysts to import CSV data and query it alongside the existing database. All queries are tracked in an audit log, which the README lists as a security feature. A Docker image is available at a separate repository (ankane/blazer-docker) for teams that prefer a containerised deployment outside a Rails app.

## What Blazer Does Not Do

Blazer is a SQL-first tool. It does not provide a visual query builder for users who cannot write SQL: every query starts as a SQL statement in the editor. This is a hard constraint rather than a configuration option. It also does not provide a native mobile application or a REST API for embedding charts in external sites. The chart types are limited to what the library renders for SQL result sets; custom visualisations require extending the application beyond what the gem provides. Encrypted data presents a specific limitation: the README notes that searching encrypted columns requires using the blind_index gem alongside Blazer and configuring a custom `transform_variable` lambda to hash input values before they reach the query. This adds complexity for applications with encrypted fields in the schema. For applications that need to shield sensitive data from analysts altogether, the README points to the Hypershield gem from the same maintainer, which can mask columns in the database view that Blazer connects to. Blazer does not attempt to handle these concerns itself; it delegates them to companion gems. The approach keeps the core gem focused but means a production deployment for a team that handles personal data requires additional configuration steps beyond the base install.

## Licence and Maintenance

Blazer is MIT-licensed. The repository includes a CHANGELOG.md for tracking version-to-version changes, a Gemfile listing development dependencies, and a test directory. The last push to the repository was on 2026-09-25. The project has no GitHub releases; version tags are managed through the RubyGems release process rather than GitHub releases. The README does not reference a minimum Ruby or Rails version, so checking the gemspec or the gemfiles directory for compatibility constraints is advisable before adding Blazer to an application running an older Rails version. The repository includes a gemfiles/ directory that lists multiple gemfiles for testing against different Rails and database adapter combinations, which indicates the project tests against a range of dependency versions. The app/ directory inside the gem contains the standard Rails engine layout: assets, controllers, helpers, mailers, models, and views. The config/ directory holds routes and initializer files. The lib/blazer directory is where the core library code lives, with the main module entry point being blazer.gemspec at the root. Developers who want to extend Blazer or debug an unexpected query result can follow this structure to identify which part of the codebase is responsible.

## Conclusion

Blazer fits Ruby on Rails teams that want SQL-based analytics and alerting inside their existing application without standing up a separate BI service. It is the right tool when the data analysts on the team already know SQL and the engineering team wants to avoid a separate infrastructure component. It is a poor fit for organisations whose data lives primarily outside a relational database, or for teams that need a visual query builder for non-technical users who cannot write SQL. Check the CHANGELOG.md before upgrading, since the README does not document breaking changes inline.

## FAQ

### What is Blazer on the internet?

In a software context, Blazer (ankane/blazer) is a Ruby on Rails gem that adds a SQL query editor, chart builder, dashboard system, and data-check alerting to any Rails application. It is unrelated to the clothing item of the same name.

### How do I use Blazer in a Rails app?

Add gem 'blazer' to the Gemfile, run 'rails generate blazer:install' and 'rails db:migrate', then mount the engine in config/routes.rb with 'mount Blazer::Engine, at: "blazer"'. Set BLAZER_DATABASE_URL in production and protect the route with your application's authentication system.

### Does Blazer support databases other than PostgreSQL?

Yes. The README lists PostgreSQL, MySQL, Redshift, and a longer set of supported data sources. Multiple sources can be configured in a single Blazer installation, allowing queries across different databases from the same interface.

## Sources

- [ankane/blazer on GitHub](https://github.com/ankane/blazer)
- [Issues](https://github.com/ankane/blazer/issues)
- [License: MIT](https://github.com/ankane/blazer/blob/master/LICENSE)
- [README](https://github.com/ankane/blazer/blob/master/README.md)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/ankane-blazer
