我有一个已经部署在Elastic Beanstalk上的node.js应用程序。部署了节点应用程序的EC2实例正在运行Ubuntu 16.04.5 LTS。我正在尝试使用.ebextensions文件夹中的datadog的配置文件将Datadog APM与Elastic Beanstalk集成。我正在按照其文档页面(https://docs.datadoghq.com/integrations/amazon_elasticbeanstalk/#alternate-datadog-agent-configuration)
上的说明进行操作即使我按照上述所有步骤操作,我仍然在AWS ELB上遇到以下错误。
我的Datadog配置文件代码:
# .ebextensions/99datadog.config
option_settings:
- namespace: aws:elasticbeanstalk:application:environment
option_name: DD_API_KEY
value : "MY_API_KEY"
- namespace: aws:elasticbeanstalk:application:environment
option_name: DD_AGENT_VERSION
value : "7.16.0"
files:
"/configure_datadog_yaml.sh":
mode: "000700"
owner: root
group: root
content: |
#!/bin/bash
DD_KEY="$(/opt/elasticbeanstalk/bin/get-config environment -k DD_API_KEY)"
sed 's/api_key:.*/api_key: '$DD_KEY'/' /etc/datadog-agent/datadog.yaml.example > /etc/datadog-agent/datadog.yaml
echo -e "process_config:\n enabled: \"true\"\n" >> /etc/datadog-agent/datadog.yaml
"/datadog/datadog.repo":
mode: "000644"
owner: root
group: root
content: |
[datadog]
name = Datadog,Inc.
baseurl = https://yum.datadoghq.com/stable/7/x86_64/
enabled=1
gpgcheck=1
gpgkey=https://yum.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public
"/datadog/hooks/99start_datadog.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
STATUS=`sudo initctl status datadog-agent`
if [[ "$STATUS" == *"datadog-agent start/running"* ]]
then
echo "Agent already running"
else
echo "Agent starting..."
sudo initctl start datadog-agent
fi
"/datadog/hooks/99stop_datadog.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
STATUS=`sudo initctl status datadog-agent`
if [[ "$STATUS" == *"datadog-agent stop/waiting"* ]]
then
echo "Agent already stopped"
else
echo "Agent stopping..."
sudo initctl stop datadog-agent
fi
container_commands:
02mkdir_appdeploy_post:
test: '[ ! -d /opt/elasticbeanstalk/hooks/appdeploy/post ]'
command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/post"
02mkdir_configdeploy_post:
test: '[ ! -d /opt/elasticbeanstalk/hooks/configdeploy/post ]'
command: "mkdir /opt/elasticbeanstalk/hooks/configdeploy/post"
10appdeploy_pre_stop:
test: '[ -f /datadog/hooks/99stop_datadog.sh ]'
command: "cp /datadog/hooks/99stop_datadog.sh /opt/elasticbeanstalk/hooks/appdeploy/pre/"
11appdeploy_post_start:
test: '[ -f /datadog/hooks/99start_datadog.sh ]'
command: "cp /datadog/hooks/99start_datadog.sh /opt/elasticbeanstalk/hooks/appdeploy/post/"
20preinit_stop:
test: '[ -f /datadog/hooks/99stop_datadog.sh ]'
command: "cp /datadog/hooks/99stop_datadog.sh /opt/elasticbeanstalk/hooks/preinit"
21postinit_start:
test: '[ -f /datadog/hooks/99start_datadog.sh ]'
command: "cp /datadog/hooks/99start_datadog.sh /opt/elasticbeanstalk/hooks/postinit"
30configdeploy_pre_stop:
test: '[ -f /datadog/hooks/99stop_datadog.sh ]'
command: "cp /datadog/hooks/99stop_datadog.sh /opt/elasticbeanstalk/hooks/configdeploy/pre/"
31configdeploy_post_start:
test: '[ -f /datadog/hooks/99start_datadog.sh ]'
command: "cp /datadog/hooks/99start_datadog.sh /opt/elasticbeanstalk/hooks/configdeploy/post/"
90install_datadog:
test: '[ -f /datadog/datadog.repo ]'
command: 'cp /datadog/datadog.repo /etc/yum.repos.d/datadog.repo; yum -y makecache; DD_AGENT_VERSION="$(/opt/elasticbeanstalk/bin/get-config environment -k DD_AGENT_VERSION)"; yum -y install datadog-agent${DD_AGENT_VERSION:+-$DD_AGENT_VERSION-1}'
91setup_datadog:
test: '[ -x /configure_datadog_yaml.sh ]'
command: "/configure_datadog_yaml.sh"
即使在启动和停止脚本中用 systemctl 替换了 initctl 之后,我仍然遇到相同的错误。
无法理解我要去哪里。请帮忙!