documentation
documentation copied to clipboard
Heroku log drain information is missing information on how to set env
Documentation Page
https://docs.datadoghq.com/logs/guide/collect-heroku-logs/
Issue Description
I was trying to set up logging on a new environment for our app to fully transition off of an old provider.
I needed to set the env so I could view the logs and filter them by environment.
Our app runs on Heroku.
This page could be more explicit on how to set the env
for a given application.
What I've discovered is that setting the env
via the log drain is the only way to set the env
(at least for logging in a Heroku application).
For example:
heroku drains:add 'https://http-intake.logs.datadoghq.com/v1/input/<DD_API_KEY>?ddsource=heroku&env=<ENV>&service=<SERVICE>&host=<HOST>' -a <APPLICATION_NAME>
^^^^^^^^^
Other things which I tried, had no effect, such as:
- setting the
DD_ENV
env variable - setting the
DD_TAGS='env:my-env'
I would suggest something like
- Replace <ENV> with your application's environment (This supercedes DD_ENV).
A better explanation of how logs are set up in Heroku can save hours for developers trying to setup Datadog for the first time.
This seems to have been resolved with #11181. However, 2 things to note:
- v2 came out since that update (
https://http-intake.logs.datadoghq.com/api/v2/logs
) - With it set up this way when I search logs by
env
I have to do it with "@" prefixed, eg@env:
instead ofenv:
, and I can't group log monitors byenv
. It's not seen as a tag but as an attribute, if I understand correctly.
Looking at the Logs API Send Logs endpoint it seems to expect ddtags
instead of explicitly passing env
.
What it says in the documentation to do:
heroku drains:add 'https://http-intake.logs.datadoghq.com/api/v2/logs/?dd-api-key=<DD_API_KEY>&ddsource=heroku&env=<ENV>&service=<SERVICE>&host=<HOST>' -a <APPLICATION_NAME>
What it probably should be:
heroku drains:add 'https://http-intake.logs.datadoghq.com/api/v2/logs/?dd-api-key=<DD_API_KEY>&ddsource=heroku&ddtags=env:<ENV>&service=<SERVICE>&host=<HOST>' -a <APPLICATION_NAME>
Not sure about host
but in the API docs it has hostname
so that may need to change as well.
service
, ddsource
, and dd-api-key
are working correctly for me.
@sarina-dd Do you have any insights into this since you worked on the PR mentioned above last year?
In my case, https://docs.datadoghq.com/logs/guide/collect-heroku-logs/ didn't show the correct region of my account.
Ex.
heroku drains:add "https://http-intake.logs.datadoghq.com/api/v2/logs?dd-api-key=<DD_API_KEY>&ddsource=heroku&env=<ENV>&service=<SERVICE>&host=<HOST>" -a <APPLICATION_NAME>
The above instruction is for us1
region. If you use the different region like eu
, you should use the following:
heroku drains:add "https://http-intake.logs.datadoghq.eu/api/v2/logs?dd-api-key=<DD_API_KEY>&ddsource=heroku&env=<ENV>&service=<SERVICE>&host=<HOST>" -a <APPLICATION_NAME>
You can confirm that with pull-down of sidebar.