Heroku Postgres Metrics Logs
Last updated December 09, 2022
Heroku Postgres Standard and Premium Tier database users see database-related events on their app’s log stream. These events are useful for recording and analyzing usage over time.
Heroku Postgres Metrics that appear via
heroku-postgres are separate from standard alerts emitted from Postgres itself that appear for all applications via
Nov 09 23:56:02 source=HEROKU_POSTGRESQL_SILVER addon=postgresql-devcenter-123456 sample#current_transaction=54017686 sample#db_size=16012956319bytes sample#tables=97 sample#active-connections=7 sample#waiting-connections=0 sample#index-cache-hit-rate=0.9239 sample#table-cache-hit-rate=0.93609 sample#load-avg-1m=0 sample#load-avg-5m=0 sample#load-avg-15m=0 sample#read-iops=0 sample#write-iops=0.13333 sample#tmp-disk-used=33849344 sample#tmp-disk-available=72944943104 sample#memory-total=4044960kB sample#memory-free=46920kB sample#memory-cached=3667532kB sample#memory-postgres=20824kB sample#wal-percentage-used=0.06512959334021144
The following attributes appear in application logs for all standard and premium tier databases.
source: The database attachment name that the measurements relate to (for example, HEROKU_POSTGRESQL_VIOLET).
addon: The database addon name that the measurements relate to (for example, postgres-metric-68904).
- The log line’s timestamp is the time at which the measurements were taken.
These attributes apply to a particular database. They’re the same for single-tenant and multitenant database plans.
sample#db_size: The number of bytes contained in the database. This metric includes all table and index data on disk, including database bloat.
sample#tables: The number of tables in the database.
sample#active-connections: The number of connections established on the database.
sample#waiting-connections: Number of connections waiting on a lock to be acquired. If many connections are waiting, this metric can be a sign of mishandled database concurrency.
sample#current_transaction: The current transaction ID, which can be used to track writes over time.
sample#index-cache-hit-rate: Ratio of index lookups served from shared buffer cache, rounded to five decimal points. Heroku recommends a value of 0.99 or greater if possible. If your index hit rate is consistently less than 0.99, investigate your Expensive Queries or upgrade your database plan for more RAM.
sample#table-cache-hit-rate: Ratio of table lookups served from shared buffer cache, rounded to five decimal points. Heroku recommends a value of 0.99 or greater if possible. If your table hit rate is consistently less than 0.99, upgrade your database plan for more RAM.
sample#memory-postgres: Approximate amount of memory used by your database’s Postgres processes in kB. This metric includes shared buffer cache as well as memory for each connection.
sample#follower-lag-commits: Replication lag, measured as the number of commits that this follower is behind its leader. Replication is asynchronous so a number greater than zero doesn’t indicate an issue, however an increasing value deserves investigation. Read more in Monitoring Followers. This metric is only published for follower databases.
These metrics come directly from the server operating system. For multi-tenant plans, the metrics include other databases running on the shared server, and can be misleading when diagnosing database performance.
sample#load-avg-15m: The average system load over a period of 1 minute, 5 minutes, and 15 minutes, divided by the number of available CPUs. A
load-avgof 1.0 indicates that, on average, processes were requesting CPU resources for 100% of the timespan. This number includes I/O wait. For databases that have burstable performance, a baseline load average is guaranteed. For more information see the burstable performance section in the technical characteristic article.
sample#write-iops: Number of read or write operations in I/O sizes of 16-KB blocks.
sample#memory-total: Total amount of server memory available.
sample#memory-free: Amount of free memory available in kB.
sample#memory-cached: Amount of memory being used by the OS for page cache, in kB.
sample#memory-postgres: Amount of memory being used by Postgres in kB.
sample#tmp-disk-available: Number of bytes used/available on tmp mount.
sample#wal-percentage-used: Percentage of the WAL disk that has been used, between
1.0. See this article for more details.
The operating system is designed to maximize the amount of memory it uses for its page cache, but can sometimes release that memory if an application requests it. For an estimate of the total amount of memory available to your server, add
These 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.
sample#client_active: The number of client connections to the pooler that have an active server connection assignment.
sample#client_waiting: The number of client connections to the pooler that are waiting for a server connection assignment.
sample#server_active: The number of server connections that are currently assigned to a client connection.
sample#server_idle: The number of server connections that aren’t currently assigned to a client connection.
sample#max_wait: The longest wait time of any client currently waiting for a server connection assignment.
sample#avg_query: The average query time of all queries executed through pooled connections.
sample#avg_recv: The number of bytes received from clients per second.
sample#avg_sent: The number of bytes sent to clients per second.