Monitoring Heroku Apps
Last updated October 11, 2024
Table of Contents
Monitoring will help you spot issues in advance and respond to incidents quickly. This article describes the primary monitoring tools you need to monitor all aspects of your Heroku apps and instructions on how to use them most effectively.
Heroku Enterprise customers with Premier or Signature Success Plans can request in-depth guidance on this topic from the Customer Solutions Architecture (CSA) team. Learn more about Expert Coaching Sessions here or contact your Salesforce account executive.
Logging
Logging tools collect and store your Heroku app and database logs. During an incident, you can use logs to help identify what is happening and narrow down a fix. After an incident, you can refer to logs in your root cause analysis.
Set up a logging tool by installing a Heroku add-on. The Logging category includes several logging tools, with different features and retention periods, so compare the add-on’s features to your needs.
After installing an add-on, it is a good idea to set up the following:
- Make sure you’re under the log volume quota for the logging tool and plan you selected. If you’re exceeding the quota, upgrade your plan with the provider, set up log filtering, or tune the logging settings in your app.
- Learn the search functionality of your logging tool before an incident so you can dig into issues when they occur
- Tag your app logs with request IDs so you can gather all logs for a specific request
- Set up log-based alerts for platform errors that may not show up in other tools. Start with R14/R15 memory errors and H10 app crashes.
- Consider different logging libraries for your app’s language to generate structured logs, i.e. structlog for Python
Heroku retains a small number of recent log lines, but you will need to use a tool like those covered in this section to retain and search past logs.
If you have an existing logging tool that is not a Heroku add-on, you can set up a log drain to send logs to that tool. If you use Heroku Shield, you can use Private Space Logging to drain all logs from a Space to an outside tool.
Application Performance Monitoring (APM)
Application Performance Monitoring (APM) tools show details about app performance, helping identify parts of your app that may be causing slowness. Use data from an APM tool to guide your performance efforts and optimize slow endpoints.
Set up an APM tool by installing a Heroku add-on. The Monitoring category includes APM tools like New Relic APM, Scout APM, and Solarwinds AppOptics.
After you’ve provisioned the add-on and configured your app to use it, you can:
- Identify your slowest endpoints and look for opportunities to optimize them. Consider turning slow endpoints into background jobs or adopting a caching strategy.
- Examine request queue time. If queue time spikes during higher traffic, check your app’s concurrency settings. See guidance for Node and Ruby apps.
- Look at performance of external services, like external API’s and databases. If an external service slows web requests, consider backgrounding the work.
Learn more about acting on insights from your APM tool.
Error Monitoring
Error monitoring tools capture exceptions or errors thrown by your app, whether they originate from your code, dependencies, or a framework. With error monitoring, you can view an error’s stack trace and drill down to its root cause. During an incident, seeing the errors your app is throwing can help you troubleshoot more quickly.
Set up error monitoring by installing a Heroku add-on. The Errors and Exceptions category includes error monitoring tools like Bugsnag, Raygun, and Sentry.
After installing an add-on, add its library to your app to capture errors. See documentation for each add-on for details.
Once you’ve installed the error monitoring tool and its library:
- Configure the tool to alert you to spikes in errors. Send those alerts to an alert management tool to page your team
- Integrate the tool with GitHub to tie new errors to specific deploys
Platform Monitoring
Platform monitoring tools capture dyno metrics, Postgres metrics, Key-Value Store metrics, and router metrics from the Heroku platform, and present them in visual dashboards. You can use these tools to surface issues such as a dyno running out of memory or a rapid increase in database load.
Set up platform monitoring by installing a Heroku add-on. The Monitoring category includes platform monitoring tools like Librato and AppOptics.
Enable log-runtime-metrics to expose dyno-level metrics to your platform monitoring tools via your Heroku logs.
Once you have the tool installed, review and set alerts on key metrics:
- Review Heroku metrics that your chosen tool natively supports. Librato summarizes the Heroku metrics that it surfaces by default.
- Set alerts on key system metrics like memory use, dyno load, web response time, and error rate
See Monitoring Heroku Postgres for tips on using a platform monitoring tool to monitor your database.
Heroku Threshold Alerting
Heroku threshold alerting notifies you when error rate or response time gets too high. Generally, Heroku recommends response times of 500ms or less. Threshold alerting provides near-real-time notice of a performance issue, so you can resolve it before it causes downtime.
Set up threshold alerting for an app by enabling it in the Heroku Dashboard.
When setting up threshold alerting:
- Set response time threshold and sensitivity low enough to catch issues in their early stages, but high enough to avoid false alarms
- Send alerts to an alert management tool via the tool’s e-mail integration, to page your team if there is an issue. If you don’t have an alert monitoring tool, send alerts to a team-wide distribution list.
Uptime Monitoring
Uptime monitoring tools measure your app’s availability from an end user’s perspective. These tools may detect issues that other tools can’t, like an invalid DNS record, CDN issue, or slow response times in a certain region.
Set up uptime monitoring by installing a Heroku add-on. The Monitoring category includes uptime monitoring tools like Pingdom and Better Uptime.
When using an uptime monitoring tool:
- Configure the tool to check app availability from different regions
- Use your publicly-facing URL to ensure the uptime check catches DNS or CDN issues
- Integrate with an alert management tool to page your team if there is an issue
Heroku Notifications for Apps and Databases
Heroku sends e-mail notifications for certain app and database events, including:
- Heroku Postgres, Heroku Key-Value Store, and Apache Kafka on Heroku notifications including upcoming maintenance and maintenance status
- End of life for a Heroku Stack used by the app
- Heroku Connect errors that need user intervention
You will receive notifications via e-mail if you are a collaborator on an app or admin on the team containing the app. To manage Heroku Connect alerts, go to Settings -> Manage Connection -> Access
in the Connect dashboard.
Non-urgent notifications are easy to ignore and forget. Ensure that you read the emails and follow their instructions.
Heroku Status
Heroku Status provides updates on platform incidents and maintenance events. Maintenance alerts allow your team to prepare in advance. Incident alerts inform your team of issues that may impact your app, database, or Heroku tooling.
Subscribe to Heroku Status alerts to receive an e-mail notification when they occur.
When setting up status notifications:
- Send critical incidents to an alert management tool, using the alert management tool’s e-mail integration. Choose “Critical incidents only” to page your team only when the incident could directly impact your production app
- Send status notifications to a team distribution list, so all team members are in the loop
Alert Management
Alert management tools notify your team of alerts from your monitoring tools.
You can choose who is “on call” to receive alerts and choose who else to notify if that person is unavailable.
Set up an alert management tool like PagerDuty or OpsGenie.
After setting up a tool:
- Send alerts from your monitoring tools to the alert management tool, using a pre-built integration or e-mail
- Set up an alerting policy for your team, specifying who gets notified when
- Make sure your alerting policy includes backup team members to respond if the primary team member is unavailable
Database Monitoring
Database performance impacts app performance. See guidance for monitoring your Heroku Postgres database.