Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running dd-agent in heroku containers #381

Open
Parad0X opened this issue Sep 8, 2024 · 2 comments
Open

Running dd-agent in heroku containers #381

Parad0X opened this issue Sep 8, 2024 · 2 comments

Comments

@Parad0X
Copy link

Parad0X commented Sep 8, 2024

I'm trying to follow the instructions to setup dd-agent using Docker containers in Heroku but I ran into two issues:

  1. datadog-agent won't start without DD_HOSTNAME being set. There's code in datadog.sh that sets it but how is DD_HOSTAME supposed to be set without the buildpack?

if [ -z "$DD_HOSTNAME" ]; then
if [ "$DD_DYNO_HOST" == "true" ]; then
# Set the hostname to dyno name and ensure rfc1123 compliance.
HAN="$(echo "$HEROKU_APP_NAME" | sed -e 's/[^a-zA-Z0-9-]/-/g' -e 's/^-//g')"
if [ "$HAN" != "$HEROKU_APP_NAME" ]; then
if [ "$DD_LOG_LEVEL_LOWER" == "debug" ]; then
echo "WARNING: The appname \"$HEROKU_APP_NAME\" contains invalid characters. Using \"$HAN\" instead."
fi
fi
D="$(echo "$DYNO" | sed -e 's/[^a-zA-Z0-9.-]/-/g' -e 's/^-//g')"
export DD_HOSTNAME="$HAN.$D"
else
# Set the hostname to the dyno host
DD_HOSTNAME="$(echo "$DYNOHOST" | sed -e 's/[^a-zA-Z0-9-]/-/g' -e 's/^-//g')"
export DD_HOSTNAME
fi
else
# Generate a warning about DD_HOSTNAME deprecation.
if [ "$DD_LOG_LEVEL_LOWER" == "debug" ]; then
echo "WARNING: DD_HOSTNAME has been set. Setting this environment variable may result in metrics errors. To remove it, run: heroku config:unset DD_HOSTNAME"
fi
fi

  1. CMD ["./scripts/entrypoint.sh"] does not start the agent. I can't find anything in Heroku documentation that would explain how to run multiple processes in a container. If I just run the script from the command line in the dyno the agent starts, there are no errors.

  2. PS. It would also be helpful to have an example of minimal datadog.yaml config file to get everything going using Docker.

@jyee
Copy link
Contributor

jyee commented Sep 16, 2024

  1. You can set DD_HOSTNAME as an environment variable in Heroku and it will be passed to the container.
  2. In a docker file, only the last CMD will be executed. The simplest way to work around this is to create a small script file that you can call from the CMD line. In that script file, you can call entrypoint.sh and start whatever other process you need.

@Parad0X
Copy link
Author

Parad0X commented Sep 16, 2024

  1. Makes sense. But in this case if I have multiple dynos which all have their unique internal host names, this information will be lost and in DD their traces will be all grouped together.
  2. Yes but there's also heroku.yml which specifies a run command for each type of dyno and they all share the same Dockerfile so I don't see how that's going to work.

Thank you for your help, @jyee 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants