Funnel metrics from multiple Heroku apps into DataDog using statsd.
Supported Heroku metrics:
- Heroku Router response times, status codes, etc.
- Application errors
- Heroku Postgres metrics
- Heroku Dyno runtime metrics
$ git clone https://github.com/ascent-technologies/heroku-datadog-drain.git
$ cd heroku-datadog-drain
$ docker build . --tag <desired-image-name>
# Create a .env file at the root with required environment variables
# defined within (See configuration section below)
#
# Start the application server
docker run --rm -it -p <port>:<port> --env-file .env <desired-image-name> npm start
# Run unit tests
docker run --rm -it -p <port>:<port> --env-file .env <desired-image-name> npm test
DEBUG= # Optional. If DEBUG is set, a lot of stuff will be logged :)
STATSD_URL=.. # Optional. Default: statsd://localhost:8125
ALLOWED_APPS=my-app,.. # Required. Comma seperated list of app names
<APP_NAME>_PASSWORD=.. # Required. One per allowed app where <APP-NAME> corresponds to an app name from ALLOWED_APPS
<APP_NAME>_TAGS=mytag,.. # Optional. Comma seperated list of default tags for each app
<APP_NAME>_PREFIX=yee # Optional. String to be prepended to all metrics from a given app
Example for cds with Heroku slug - ascent-cds-staging
DEBUG=true
STATSD_URL=https://localhost:8125
ALLOWED_APPS=ascent-cds-staging
ASCENT_CDS_STAGING_PASSWORD=somepass
ASCENT_CDS_STAGING_TAGS=app:cds,env:staging
ASCENT_CDS_STAGING_PREFIX=someprefix
# The password should be a secure, randomly generated password.
$ heroku drains:add https://<your-app-slug>:<password>@<this-drain-app-slug>.herokuapp.com --app <your-app-slug>
NOTE: This can be done directly through the Heroku dashboard by setting or updating the ALLOWED_APPS
variable
# The ALLOWED_APPS variable will already be configured in Heroku for this drain, so you will need to
# grab the value of this variable first from Heroku and then append <your-app-slug> as another
# comma seperated value.
HEROKU_DRAIN_ALLOWED_APPS="$(heroku config:get ALLOWED_APPS --app <this-drain-app-slug>)"
# Check the output of the variable and confirm it is correct.
echo $HEROKU_DRAIN_ALLOWED_APPS
# NOTE: You need to set the ALLOWED_APPS and <YOUR_APP_SLUG>_PASSWORD at the same
# time otherwise the collection for metrics of all other apps will STOP.
#
# The password is the one generated when adding the drain to the Heroku application in the above section
heroku config:set ALLOWED_APPS=$HEROKU_DRAIN_ALLOWED_APPS,<your_app_slug> <YOUR_APP_SLUG>_PASSWORD=<password> <YOUR_APP_SLUG>_TAGS=<tags> --app <this-drain-app-slug>