How do I monitor Heroku applications?

Heroku is a cloud Platform as a Service (PaaS) that enables you to build and run applications in the cloud. Applications deployed to Heroku are usually run through one or more buildpacks that provide framework and runtime support.

The following guidelines explain how to enable Dynatrace monitoring for your Heroku applications by adding a Dynatrace Heroku buildpack to your application's Heroku configuration. Note: The Dynatrace Heroku buildpack enables you to monitor all supported languages on Linux systems

What you need

  • Dynatrace environment credentials
  • Heroku CLI

Also, be sure to review the list of supported applications and versions.

Installation

These guidelines explain how to integrate Dynatrace OneAgent into your Heroku dynos and begin monitoring your Heroku applications.

Generate a PaaS token

The first step is to get your environment ID and generate a PaaS token for your Dynatrace environment.

  1. Login with your Dynatrace account.

  2. Select Deploy Dynatrace from the navigation menu.

  3. Click the Set up PaaS integration button.

  4. Your environment ID appears in the Environment ID text box. You'll need this ID to link your Dynatrace account with your PaaS environment. Click Copy to copy the ID to the clipboard. You can do this at any time by revisiting this page.

  5. To generate a PaaS token, click the Generate new token button. The PaaS token is essentially an API token that's used in combination with your environment ID to download Dynatrace OneAgent. As you will notice, there is already a default InstallerDownload token available that you could alternatively use. However, for security reasons, it is recommended that you create several discrete tokens for different environments.

  6. Type in a meaningful name for your PaaS token. A meaningful token name might be the name of the PaaS platform you want to monitor (for example, azure, cloud-foundry, or openshift). To view and manage your existing PaaS tokens, go to Settings -> Integration -> Platform as a Service.

  7. Click Generate to create the PaaS token. The newly created PaaS token will appear in the list below. Click Copy to copy the generated token to the clipboard. You can do this at any time by revisiting this page and clicking Show token next to the relevant PaaS token.

Get the Heroku CLI

To configure Heroku applications to use the Dynatrace Heroku buildpack, you can either use the Heroku CLI or you can configure your applications using the Heroku dashboard.

Add the Dynatrace Heroku buildpack

To integrate Dynatrace OneAgent into your existing application, you need to add the Dynatrace Heroku buildpack to your application's buildpacks and set your Dynatrace environment ID and PaaS token using the commands below.

# Add the Dynatrace buildpack
heroku buildpacks:add https://github.com/Dynatrace/heroku-buildpack-dynatrace.git

# Set required credentials to your Dynatrace environment
heroku config:set DT_TENANT=<environmentID>
heroku config:set DT_API_TOKEN=<token>

# Set hostname in Dynatrace
heroku config:set DT_HOST_ID=$(heroku apps:info|grep ===|cut -d' ' -f2)

# Deploy to Heroku
git push heroku master

Once you push these changes, the buildpack installs Dynatrace OneAgent to automatically monitor your application.

Additional configuration

The Dynatrace Heroku buildpack supports the following configurations:

Environment variable Description
DT_TENANT Your Dynatrace environment ID
DT_API_TOKEN The PaaS token for integrating your Dynatrace environment with Heroku
DT_HOST_ID The name to be used for the dyno entity in Dynatrace
DT_API_URL (Optional) Replace with your Dynatrace server URL, including the environment ID. For example, https://{your-managed-cluster.com}/e/{environmentid}/api
DT_DOWNLOAD_URL (Optional) A direct download URL for Dynatrace OneAgent. If this environment variable is set, the buildpack will download OneAgent from this location
SSL_MODE (Optional) Set to all if you want to accept all self-signed SSL certificates
DT_TAGS (Optional) The tags you want to add to the monitored apps

Update OneAgent for Heroku

When a new version of OneAgent becomes available, you need to trigger a re-run of the buildpack in Heroku. The Dynatrace buildpack will automatically fetch the latest version of OneAgent.

If you've specified a default OneAgent install version for new hosts and applications in your OneAgent updates settings, the Heroku buildpack will automatically fetch the defined default version of OneAgent.