You can stream your Heroku logs to New Relic using Heroku's built-in Logplex router. Here we explain how to stream logs to New Relic using Heroku syslog drains.
Requirements
重要
Currently, our Heroku syslog endpoint only supports accounts in our US data center.
Ensure the following before configuring log forwarding from Heroku:
- Your New Relic user account has the Admin role assigned to it.
- The account you wish to send logs to has at least one Insights Insert API Key associated with it.
Create a Heroku syslog drain
Download and install the Heroku CLI.
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.$ heroku drains:add syslog+tls://newrelic.syslog.nr-data.net:6515 -a YOUR_APP_NAME
Run the following command and copy the Heroku syslog drain token from the
token
attribute:$ 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://logs.example.com"}
Register a Heroku syslog drain
Next, you'll need to register your newly created Heroku syslog drain in New Relic:
Login to New Relic Logs and click Add more data sources.
Click the Heroku tile under Log ingestion.
Choose the New Relic account to stream your Heroku application logs to and click Continue.
Paste your newly created Heroku drain token in the Heroku drain token field.
Select an Insights insert API key from the drop-down.
Click Add Heroku drain log to complete registration.
重要
Heroku doesn't currently support customizing the format of logs sent from Logplex. For more information, check Heroku's documentation on their log format.
View log data
Once logs are streaming you can view them using:
New Relic tools for running NRQL queries. For example, you can execute a query like this:
SELECT * FROM Log
What's next?
Now that you've enabled Logs, here are some potential next steps:
- Explore your data using the Logs UI.
- Configure your agent to see contextual log data, such as distributed tracing, stack traces, application logs, and more.
- Query your data and create custom dashboards or alerts.
If no data appears after you enable log management, follow the troubleshooting procedures.
その他のヘルプ
さらに支援が必要な場合は、これらのサポートと学習リソースを確認してください:
- Explorers Hubでは、コミュニティからのサポートを受けたり、ディスカッションに参加したりすることができます。
- 当社サイトで答えを見つけて、サポートポータルの使用方法を確認してください。
- Linux、Windows、およびmacOS向けトラブルシューティングツールであるNew Relic Diagnosticsを実行してください。
- New Relicのデータセキュリティとライセンスドキュメント をご確認ください。