Skip Navigation
Show nav
Heroku Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log inorSign up
View categories

Categories

  • Heroku Architecture
    • Dynos (app containers)
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Command Line
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery
    • Continuous Integration
  • Language Support
    • Node.js
    • Ruby
      • Rails Support
      • Working with Bundler
    • Python
      • Background Jobs in Python
      • Working with Django
    • Java
      • Working with Maven
      • Java Database Operations
      • Working with the Play Framework
      • Working with Spring Boot
      • Java Advanced Topics
    • PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
    • Heroku Data For Redis
    • Apache Kafka on Heroku
    • Other Data Stores
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
    • Compliance
  • Heroku Enterprise
    • Private Spaces
      • Infrastructure Networking
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
    • Single Sign-on (SSO)
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
  • Databases & Data Management
  • Heroku Postgres
  • Postgres Getting Started
  • Getting Started: Monitoring a Heroku Postgres Database

Getting Started: Monitoring a Heroku Postgres Database

English — 日本語に切り替える

Last updated December 14, 2022

Table of Contents

  • Before You Begin
  • Explore the Postgres Log
  • Install a Monitoring Add-on
  • Review Database Metrics
  • Next Steps

Starting November 28, 2022, free Heroku Dynos, free Heroku Postgres, and free Heroku Data for Redis® plans will no longer be available. If you have apps using any of these resources, you must upgrade to paid plans by this date to ensure your apps continue to run and retain your data. Eligible students can apply for platform credits through our new Heroku for GitHub Students program. See our blog and FAQ for more info.

Heroku Postgres is a managed SQL database service provided directly by Heroku. You can access a Heroku Postgres database from any language with a PostgreSQL driver, including all languages officially supported by Heroku.

Heroku Postgres provides database and server metrics that give information on the status of your instance. Understanding and monitoring these metrics ensures the health of your database as your applications run and scale. Monitoring can also help you tune, debug, and troubleshoot your application. If you have a production database, make sure you’re monitoring it.

In this getting started, you learn how to:

  • View the Postgres log
  • Review monitoring add-on options
  • Identify which database metrics to track

Before You Begin

You must have a Heroku Postgres database provisioned before you can proceed. Use the heroku addons command to determine whether your app already has Heroku Postgres provisioned:

$ heroku addons
Add-on                                         Plan  Price   State
────────────────────────────────────────────  ─────  ──────  ───────
heroku-postgresql (postgresql-concave-52656)   mini  $5/month created

To learn how to create a Heroku Postgres database, see Provisioning Heroku Postgres.

Explore the Postgres Log

You can view logs with the Heroku CLI, the dashboard, your logging add-on, or in your log drain.

Heroku Postgres logs to the logplex which collates and publishes your application’s log-stream. You can isolate Heroku Postgres events with the heroku logs command by filtering for the postgres process.

$ heroku logs -p heroku-postgres -a heroku-101-demo-app
2022-04-21T07:46:55.000000+00:00 app[heroku-postgres]: source=HEROKU_POSTGRESQL_COBALT addon=postgresql-demo sample#current_transaction=509 sample#db_size=8426031bytes sample#tables=0 sample#active-connections=11 sample#waiting-connections=0 sample#index-cache-hit-rate=0 sample#table-cache-hit-rate=0 sample#load-avg-1m=0.02 sample#load-avg-5m=0.005 sample#load-avg-15m=0 sample#read-iops=0 sample#write-iops=0.10204 sample#tmp-disk-used=543600640 sample#tmp-disk-available=72435191808 sample#memory-total=3958708kB sample#memory-free=69612kB sample#memory-cached=3405616kB sample#memory-postgres=22080kB sample#wal-percentage-used=0.06428126026622091
...

Use the --tail option to access real-time log entries:

$ heroku logs -p heroku-postgres -a heroku-101-demo-app  --tail

When you’re done, press Ctrl+C to return to the prompt. A real-time tail session automatically terminates after one hour of inactivity. Use the --source (or -s) and --dyno (or -d) filtering argument to fetch logs with a certain source, a certain dyno, or both:

$ heroku logs --source my-application --dyno worker

If you don’t want to manually sift through logs, you can install a monitoring add-on.

Install a Monitoring Add-on

The most effective way to track database metrics is to install a platform monitoring add-on.

A full list of monitoring add-ons can be found on the Heroku Elements Marketplace. Many of these add-ons offer a free plan to get started. See your add-on’s documentation for instructions on retrieving logs.

Review Database Metrics

Heroku Postgres provides database and server metrics that give information on the status of your instance. Understanding and monitoring these metrics ensures the health of your database as your applications run and scale. Monitoring can also help you identify bottlenecks, bugs, and performance issues. You can look for these metrics in the log or in the dashboard for your monitoring add-on.

You can track metrics for the following:

  • Database attributes apply to a particular database.
  • Server come directly from the server operating system.
  • pg_bouncer metrics are included for any Heroku Postgres server that has a PgBouncer pooler attachment. These metrics are a subset of those viewable by running the SHOW POOLS; command when connected to PgBouncer’s special internal database.

For more information about the different available metrics, see Heroku Postgres Metrics Logs. For a list of suggested metrics, see Monitoring Heroku Postgres.

Next Steps

Learn more about monitoring Heroku Postgres databases with the following content:

  • Monitoring Heroku Postgres
  • Managing Heroku Postgres using the CLI
  • Understanding Heroku Postgres Log Statements and Common Errors
  • Heroku Postgres and Connect Learning Journey

Keep reading

  • Postgres Getting Started

Feedback

Log in to submit feedback.

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Podcasts
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing

Subscribe to our monthly newsletter

Your email address:

  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Heroku Podcasts
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Facebook
  • Instagram
  • Github
  • LinkedIn
  • YouTube
Heroku is acompany

 © Salesforce.com

  • heroku.com
  • Terms of Service
  • Privacy
  • Cookies
  • Cookie Preferences