For this example, I have a simple Flask application called datacrunch-consulting that is deployed to Heroku via GitHub integration. Starting with GitHub, you can create a repository. Then, use GitHub Desktop to clone/push code back to GitHub without using the command line. Linking the repository with Heroku allows the application to deploy every time a push is made to your repository, great for continuous integration / continus deployment.
See GitHub repository here: https://github.com/pnvnd/flaskapp or use your own Heroku app.
We’ll need to make some adjustments to your Heroku Procfile:
newrelic-admin run-program gunicorn -b "0.0.0.0:$PORT" -w 3 --chdir datacrunch-consulting webserver:flaskapp
We’ll go over how to setup the following in New Relic One:
New Relic APMWayne - Freedatacrunch-consultingSubmit Order Form

Reveal Config VarsNEW_RELIC_APP_NAMENEW_RELIC_LICENSE_KEYNEW_RELIC_LOG

NEW_RELIC_APP_NAME to give your application a name. This is what shows up in New Relic.NEW_RELIC_LICENSE_KEY to have the license key for the New Relic account you want data ingested into
With the APM agent installed on Heroku, you can get Real User Monitoring to track browser sessions, which browser is being used, which landing page the user is getting errors (if any), and geographical location of your users.
Add more data on the top-right and select ` Browser Metrics`Enable via New Relic APM and select your application from the selection box.


Heroku apps on the free tier shuts down the app after 30 minutes of inactivity. When someone accesses the Heroku app after inactivity, it will cold start and may take a minute to load. Having a simple synthetics ping test every 15 minutes will keep the Heroku app up to avoid “cold starts”.
Text validation (optional), add a string Welcome! (or whatever string that appears on your endpoint)Verify SSL to check for expired certificates

General Instructions here
Download and install the Heorku CLI:
https://devcenter.heroku.com/articles/heroku-cli
Check if Heroku is installed:
heroku --version
Update Heroku CLI as needed:
heroku update
Log in:
heroku login

Check Environment variables, in case you can’t get to Heroku Dashboard > Settings:
PowerShell: heroku run env --app datacrunch-consulting | findstr -i NEW_RELIC

heroku config:set NEW_RELIC_LOG='stdout' --app datacrunch-consulting
heroku config:set NEW_RELIC_APP_NAME='flaskapp.heroku' --app datacrunch-consulting
heroku config:set NEW_RELIC_LICENSE_KEY='a1b2c3d4e5f6g7h8i9j0NRAL' --app datacrunch-consulting
Add Drain Logs
heroku drains:add syslog+tls://newrelic.syslog.nr-data.net:6515 --app datacrunch-consulting
Copy drain token:
heroku drains --app datacrunch-consulting --json

Add drain token in New Relic

Add tokens and restart Heroku Dynos: Heroku Dashboard > More > Restart all Dynos or:
heroku dyno:restart --app datacrunch-consulting
Go to New Relic One > Logs > Patterns to see logs, and any aggregated log messages based on patterns:

Query your data with NRQL to set up alerts based on log messages

Alerts & AI > Notification ChannelsNew notification channel and add a notification channel of your choice

Alerts & AI > Policies > New alert policyCreate alert policy

Create a conditionNext, define thresholdsSELECT count(*) from Log where plugin.type='syslog-heroku' and message like '%Shutting down%'
