Datadog agent on AWS EC2 using install_script_agent
How to send Traces from Datadog agent running in EC2 to CodeSee
Service Maps is an Enterprise-only feature
Summary
This guide will help you send trace data from your Datadog agent to CodeSee when the agent is running on AWS EC2 and installed using the install_script_agent
script.
We need to set the apm_config
> additional_endpoints
parameter in your datadog.yaml
file, but the install script ignores the environment variable that we would typically use to set this parameter. So, the script below appends the parameter to the datadog.yaml
specifically.
Install Datadog agent on AWS EC2
Create a user-data.sh
and copy its content into User Data when launching your EC2
Please refer to AWS doc on where to put your User Data: user data doc
# export required keys
export DATADOG_API_KEY=dd_api_key_here
export CODESEE_INGESTION_TOKEN=codesee_ingestion_token_here
# export required environment / service name
export DD_ENV=staging
export DD_SERVICE=example_service_name
# export for debugging / detailed logging
# export DD_TRACE_DEBUG=true
# export DD_LOG_LEVEL=debug
# export DD_TRACE_LOG_LEVEL=debug
# Install Datadog Agent
DD_API_KEY=$DATADOG_API_KEY \
bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script_agent7.sh)"
# Update Datadog Agent environment
sudo -u dd-agent -g dd-agent touch /etc/datadog-agent/environment
sudo chown $(whoami) /etc/datadog-agent/environment
cat <<EOT > /etc/datadog-agent/environment
DD_SERVICE=$DD_SERVICE
DD_ENV=$DD_ENV
DD_APM_ENABLED=true
DD_APM_NON_LOCAL_TRAFFIC=true
DD_APM_INSTRUMENTATION_ENABLED=host
DD_LOGS_INJECTION=true
DD_PROFILING_ENABLED=true
DD_APPSEC_ENABLED=true
DD_IAST_ENABLED=true
EOT
sudo chown dd-agent /etc/datadog-agent/environment
# Set CodeSee token via Datadog config file
sudo chown $(whoami) /etc/datadog-agent/datadog.yaml
sudo cat <<EOT > /etc/datadog-agent/datadog.yaml
api_key: $DATADOG_API_KEY
apm_config:
additional_endpoints:
"https://in-datadog.codesee.io":
- $CODESEE_INGESTION_TOKEN
EOT
sudo chown dd-agent /etc/datadog-agent/datadog.yaml
# Restart the Datadog Agent
sudo systemctl restart datadog-agent
# Get Datadog Agent Status
sudo systemctl status datadog-agent
Resources:
Updated 12 months ago