Datadog Heroku Buildpack
This buildpack installs the Datadog Agent in your Heroku Dyno to collect system metrics, custom application metrics and traces. To collect custom application metrics or traces, include the language appropriate DogStatsD or Datadog APM library in your application.
To add this buildpack to your project, as well as set the required environment variables:
cd <root of my project> # If this is a new Heroku project heroku create # Add the appropriate language-specific buildpack. For example: heroku buildpacks:add heroku/ruby # Enable Heroku Labs Dyno Metadata heroku labs:enable runtime-dyno-metadata -a $(heroku apps:info|grep ===|cut -d' ' -f2) # Add this buildpack and set your Datadog API key heroku buildpacks:add --index 1 https://github.com/DataDog/heroku-buildpack-datadog.git heroku config:add DD_API_KEY=<your API key> # Deploy to Heroku git push heroku master
Once complete, the Datadog Agent is started automatically when each Dyno starts.
The Datadog Agent provides a listening port on 8125 for statsd/dogstatsd metrics and events. Traces are collected on port 8126.
In addition to the environment variables shown above, there are a number of others you can set:
||Required. Your API key is available from the Datadog API integrations page. Note that this is the API key, not the application key.|
||Deprecated. WARNING: Setting the hostname manually may result in metrics continuity errors. It is recommended that you do not set this variable. Because dyno hosts are ephemeral it is recommended that you monitor based on the tags
||Optional. Set to
||Optional. Sets additional tags provided as a comma-delimited string. For example,
||Optional. Optionally set additional percentiles for your histogram metrics. See the Histogram percentiles article for more information.|
||Optional. When set, the Datadog Agent will not be run.|
||Optional. The Datadog Trace Agent (APM) is run by default. Set this to
||Optional. By default, the buildpack installs the latest version of the Datadog Agent available in the package repository. Use this variable to install older versions of the Datadog Agent (note that not all versions of the Agent may be available).|
||Optional. The Datadog Agent automatically tries to identify your environment by searching for a tag in the form
Heroku dynos are ephemeral—they can move to different host machines whenever new code is deployed, configuration changes are made, or resouce needs/availability changes. This makes Heroku flexible and responsive, but can potentially lead to a high number of reported hosts in Datadog. Datadog bills on a per-host basis, and the buildpack default is to report actual hosts, which can lead to higher than expected costs.
Depending on your use case, you may want to set your hostname so that hosts are aggregated and report a lower number. To do this, Set
true. This will cause the Agent to report the hostname as the app and dyno name (e.g.
appname.run.1234) and your host count will closely match your dyno usage. One drawback is that you may see some metrics continuity errors whenever a dyno is cycled.
This project is open source (Apache 2 License), which means we're happy for you to fork it, but we'd be even more excited to have you contribute back to it.
- If you think you've found an issue, please search the project issues and the Troubleshooting section of our Knowledge base to see if it's known.
- If you can't find anything useful, please contact our support team and send a flare. To send a flare, you'll need get to your Dyno's command line:
# From your project directory: heroku run bash # Once your Dyno has started and you are at the command line, send a flare: agent -c /app/.apt/etc/datadog-agent/datadog.yaml flare
- Finally, you can open a Github issue.
Have you fixed a bug or written a new check and want to share it? Many thanks!
In order to ease/speed up our review, here are some items you can check/improve when submitting your PR:
- Keep it small and focused. Avoid changing too many things at once.
- Summarize your PR with an explanatory title and a message describing your changes. Cross-reference any related bugs/PRs and provide steps for testing when appropriate.
- Write meaningful commit messages. The commit message should describe the reason for the change and give extra details that will allow someone later on to understand in 5 seconds the thing you've been working on for a day.
- Squash your commits. Please rebase your changes on master and squash your commits whenever possible, it keeps history cleaner and it's easier to revert things.
Earlier versions of this project were forked from the miketheman heroku-buildpack-datadog project. It was largely rewritten for Datadog's Agent version 6. Changes and more information can be found in the changelog.