ThinkNear/pg_stats_aggregator — pull request #1 by samueltb (2014-02-03 23:59:43+00:00)
Title: Periodically record stats to Librato. Provide API to run queries

* https://thinkneardev.atlassian.net/browse/IRIS-237

======================

This runs a clockwork process on a Heroku app called "pg-stats-aggregator"

Every 5m we record metrics in [Librato](https://metrics.librato.com/metrics?search=postgres) for
```
postgres.sequence_scans
postgres.index_scans
postgres.inserts
postgres.updates
postgres.deletes
postgres.index_hit_rate
postgres.cache_hit_rate
postgres.total_index_size
postgres.#{table_name}.percent_of_times_index_used
postgres.#{table_name}.percent_of_times_index_used
```

This is 39 metrics. (For 50 metrics and 3 sources reported every 5m, Librato charges us $7.50/month)

=====================

This also adds queries to rake tasks.

These rake tasks are rendered as a nice table with Hirb.

See a list of rake tasks by running
```
rake -T
```

For example, you can check table bloat by running
```
heroku run rake bloat --app pg-stats-aggregator
```

You can also run this locally by providing the environment variable DATABASE_URL.