Skip to content

Commit

Permalink
Recommend config/pghero.yml for customization [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Jun 5, 2019
1 parent 0114f7c commit 9907298
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 53 deletions.
46 changes: 6 additions & 40 deletions guides/Rails.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,54 +131,20 @@ This requires the following IAM policy:
}
```

## Multiple Databases
## Customization & Multiple Databases

Create `config/pghero.yml` with:
To customize PgHero, use `config/pghero.yml`. Create it with:

```yml
databases:
primary:
url: <%= ENV["PGHERO_DATABASE_URL"] %>
replica:
url: <%= ENV["REPLICA_DATABASE_URL"] %>
```sh
rails generate pghero:config
```

This allows you to specify multiple databases and change thresholds. Thresholds can be set globally or per-database.

## Permissions

We recommend [setting up a dedicated user](Permissions.md) for PgHero.

## Customize

Minimum time for long running queries

```ruby
PgHero.long_running_query_sec = 60 # default
```

Minimum average time for slow queries

```ruby
PgHero.slow_query_ms = 20 # default
```

Minimum calls for slow queries

```ruby
PgHero.slow_query_calls = 100 # default
```

Minimum connections for high connections warning

```ruby
PgHero.total_connections_threshold = 500 # default
```

Statement timeout for explain

```ruby
PgHero.explain_timeout_sec = 10 # default
```

## Methods

Insights
Expand Down
26 changes: 13 additions & 13 deletions lib/generators/pghero/templates/config.yml.tt
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ databases:
# Database URL (defaults to app database)
# url: <%%= ENV["DATABASE_URL"] %>

# Minimum time for long running queries
# long_running_query_sec: 60
# Add more databases
# other:
# url: <%%= ENV["OTHER_DATABASE_URL"] %>

# Minimum average time for slow queries
# slow_query_ms: 20
# Minimum time for long running queries
# long_running_query_sec: 60

# Minimum calls for slow queries
# slow_query_calls: 100
# Minimum average time for slow queries
# slow_query_ms: 20

# Minimum connections for high connections warning
# total_connections_threshold: 500
# Minimum calls for slow queries
# slow_query_calls: 100

# Statement timeout for explain
# explain_timeout_sec: 10
# Minimum connections for high connections warning
# total_connections_threshold: 500

# Add more databases
# other:
# url: <%%= ENV["OTHER_DATABASE_URL"] %>
# Statement timeout for explain
# explain_timeout_sec: 10

# Time zone (defaults to app time zone)
# time_zone: "Pacific Time (US & Canada)"

0 comments on commit 9907298

Please sign in to comment.