• Log inFree account

Stream logs from Heroku

If your log data is already being monitored by Heroku's built-in Logplex router, you can use our integration to forward and enrich your log data in New Relic. This integration uses Heroku Syslog drains.

Forwarding your Heroku logs to New Relic will give you enhanced log management capabilities to collect, process, explore, query, and alert on your log data.

Create a Heroku syslog drain

To enable our log management capabilities, start by creating a Heroku Syslog drain.

  1. Make sure your New Relic user account has the Admin role assigned to it.

  2. Download and install the Heroku CLI.

  3. Use the Heroku CLI to create a Syslog drain and attach it to the application you want to stream logs from, replacing YOUR_APP_NAME with the name of your Heroku application.

    bash
    $
    $ heroku drains:add syslog+tls://newrelic.syslog.nr-data.net:6515 -a YOUR_APP_NAME

    If you're located in Europe, run this command instead:

    bash
    $
    $ heroku drains:add syslog+tls://newrelic.syslog.eu.nr-data.net:6515 -a YOUR_APP_NAME
  4. Run the following command and copy the Heroku Syslog drain token from the token attribute:

    bash
    $
    $ heroku drains -a YOUR_APP_NAME --json
    {
    "addon": null,
    "created_at": "2018-12-04T00:59:46Z",
    "id": "906262a4-e151-45d2-b35a-a2dc0ea9e688",
    "token": "d.f14da5dc-106b-468d-b1bd-bed0ed9fa1e7",
    "updated_at": "2018-12-04T00:59:47Z",
    "url": "syslog+tls://newrelic.syslog.nr-data.net:6515
    }

Register a Heroku syslog drain

Next, you'll need to register your newly created Heroku Syslog drain in New Relic:

  1. Log in to New Relic's Logs UI and click Add more data sources.

    Add more data sources button
  2. Click the Heroku tile under Log ingestion.

    Heroku tile
  3. Choose the New Relic account to stream your Heroku application logs to, and click Continue.

  4. Paste your newly created Heroku drain token in the Heroku drain token field.

  5. Click Add Heroku drain log to complete registration.

Important

Heroku currently doesn't support customizing the format of logs sent from Logplex. For more information, see Heroku's log format documentation.

Delete a Heroku syslog drain token mapping

Complete these steps to delete a Heroku syslog drain token mapping via the New Relic UI.

  1. Make sure your New Relic user account has the admin role assigned to it.
  2. Go to the New Relic Marketplace.
  3. Search for "Heroku".
  4. Under Logging, click the Heroku tile.
  5. If you have multiple accounts, select the account that contains the drain token mappings you wish to delete and click Continue. Otherwise, go to step 6.
  6. Find the drain token mapping you want to delete and click the vertical three-dot icon next it. Next, click Delete Heroku drain token.
  7. Your Heroku drain token mapping is deleted.

Complete these steps to delete a Heroku syslog drain token mapping via REST API.

  1. Find or generate an API key with a key type of USER.
  2. Run the command below to retrieve a list of Heroku drain token mappings from your New Relic account, making sure to update values for YOUR_NR_LICENSE_KEY and YOUR_NR_ACCOUNT_ID:
bash
$
curl -H 'api-key: <var>YOUR_NR_LICENSE_KEY</var>' https://log-syslog-configuration-api.service.newrelic.com/heroku-account-mappings?accountId=<var>YOUR_NR_ACCOUNT_ID</var>

The formatted result looks something like this:

[
  {
    "herokuMappingId": 1549,
    "drainToken": "YOUR_DRAIN_TOKEN",
    "nrApiInsertKey": "YOUR_DRAIN_TOKEN_NR_API_KEY",
    "createdAt": "2022-05-13T07:47:23",
    "createdBy": "YOUR_EMAIL_ADDRESS"
  }
]

You need the herokuMappingId for each drain token that you want to remove.

  1. To delete a drain token, run the command below. Make sure to update values for YOUR_NR_LICENSE_KEY,YOUR_NR_ACCOUNT_ID, and the herokuMappingId you retrieved in the last step:

    bash
    $
    curl -XDELETE -H 'api-key: <varYOUR_NR_LICENSE_KEY</var>' https://log-syslog-configuration-api.service.newrelic.com/heroku-account-mappings/<herokuMappingId>?accountId=<var>YOUR_NR_ACCOUNT_ID</var>
  2. The API returns an HTTP 204 response and the drain token mapping is deleted.

View log data

If everything is configured correctly and your data is being collected, you should see data logs in both of these places:

SELECT * FROM Log

If no data appears after you enable our log management capabilities, follow our standard log troubleshooting procedures.

What's next?

Explore logging data across your platform with our Logs UI.

Disable log forwarding

To disable log forwarding capabilities, follow standard procedures in Heroku Syslog documentation. You do not need to do anything else in New Relic.

Copyright © 2022 New Relic Inc.