Heroku Postgres Monitoring: What You Need to Know
As a managed database, Heroku Postgres provides a number of features, services, and tools for monitoring your provisioned instance. With such a broad range of options for monitoring, how do you make sure you’re tracking the right metrics and using the right tools for the job?
This short post helps you navigate the many technical choices you face as a developer looking to build a monitoring plan for your app’s Heroku Postgres database layer. It covers the following key topics:
- Key metrics for Heroku Postgres monitoring
- Heroku Postgres monitoring tools
- Collecting and using Heroku Postgres metrics
The Hosted Graphite add-on is a full-featured monitoring tool that lets you gain insight and visibility into your Heroku Postgres service. It’s easy to set up, and it’s built on top of popular observability solutions like Graphite, Prometheus, and Grafana. Get started with Heroku Postgres monitoring with the Hosted Graphite add on!
The HG Heroku monitoring add-on will automatically pull in your Heroku data, and build dashboards for you. You'll see your own Heroku dashboards immediately after logging in to your add-on:
Key metrics for Heroku Postgres monitoring
The metrics that matter for Heroku Postgres monitoring fall into two categories: database metrics and server metrics. Database metrics describe the state of a single database, while server metrics measure the state of the infrastructure where the database is running in.
Important database metrics include query performance, active sessions, database locks, replication, and data loss. Key server metrics, on the other hand include CPU usage, memory and swap usage, disk usage, throughput, and networking statistics.
The Heroku Postgres metrics documentation explains how these numbers can be obtained from database logs and from the database itself.
Heroku Postgres monitoring tools
There are several levels of tooling available for Heroku Postgres monitoring. These include extensions available in the Postgres ecosystem, features and functionalities offered by Heroku, and external monitoring tools from other providers. These tools are oftentimes used together since they tend to complement each other’s capabilities.
The HG Heroku monitoring add-on offers the most robust solution for tracking Heroku Postgres database and server metrics. Hosted Graphite is a full-featured monitoring add-on that effectively collects and manages time-series data as well as enables data visualization through auto-generated dashboards. The add-on also monitors other components of the app such as web and worker dynos.
Another critical component in Heroku Postgres monitoring is log management and aggregation. Having a logging tool ensures that you’re able to maintain log history (since Heroku only keeps logs for a given period). It also facilitates issue resolution and root cause analysis.
Heroku also provides a CLI plugin called pg-extras that includes shortcuts to identify and fix common database performance issues.
Collecting and using Heroku Postgres metrics
We’ll now take a look at an example of using the Hosted Graphite add-on for collecting and displaying metrics. We first need to install the add-on into a Heroku app:
$ heroku addons:create hostedgraphite
Once up and running, the add-on then begins to collect and publish a default set of metrics from the app. This default set doesn’t yet include Heroku Postgres metrics, so we need to collect and send the data points ourselves.
This MetricFire blog post goes into detail about how to send metrics from a Heroku app, so we won’t repeat the steps here. The important thing is that, once set up, Hosted Graphite will start receiving the Postgres metrics being sent.
One way to check if Hosted Graphite receives the collected metrics is to check the “Live Metrics” panel of the HG Traffic dashboard:
We can then use these metrics to create a new dashboard:
In addition to displaying the metrics in a chart, we can also use it as the basis for triggering an alert.
Heroku Postgres monitoring begins with knowing what metrics to look for and which monitoring tools to use. Hosted Graphite gives you the flexibility to collect and analyze the metrics that matter without getting bogged down with unnecessary complications. Learn how easy it is to start monitoring your Heroku Postgres instance by doing the one-click install now. Discover if Hosted Graphite fits your monitoring requirements by requesting a demo.