DataDog / documentation

The source for Datadog's documentation site.
http://docs.datadoghq.com
Other
453 stars 1.06k forks source link

Heroku log drain information is missing information on how to set env #11110

Closed Eeyurrn closed 5 days ago

Eeyurrn commented 3 years ago

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:

I would suggest something like

  • Replace 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.

CaitlinWeb commented 2 years ago

This seems to have been resolved with #11181. However, 2 things to note:

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?

hsbt commented 4 months ago

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.