Amazon web services New Relic的唯一主机名';弹性豆茎上的s nrsysmond

Amazon web services New Relic的唯一主机名';弹性豆茎上的s nrsysmond,amazon-web-services,amazon-elastic-beanstalk,newrelic,Amazon Web Services,Amazon Elastic Beanstalk,Newrelic,我将nrsysmond配置为在承载通用Docker容器的弹性Beanstalk容器上运行 有没有办法得到实例索引,这样我就可以把它和一个常量结合起来?类似于Production-1、Production-2等 我使用的配置如下所示: packages: yum: newrelic-sysmond: [] rpm: newrelic: http://yum.newrelic.com/pub/newrelic/el5/x86_64/newrelic-repo-5-3.

我将nrsysmond配置为在承载通用Docker容器的弹性Beanstalk容器上运行

有没有办法得到实例索引,这样我就可以把它和一个常量结合起来?类似于Production-1、Production-2等

我使用的配置如下所示:

packages: 
  yum: 
    newrelic-sysmond: [] 
  rpm: 
    newrelic: http://yum.newrelic.com/pub/newrelic/el5/x86_64/newrelic-repo-5-3.noarch.rpm 
commands: 
  "01": 
    command: nrsysmond-config --set license_key=`/opt/elasticbeanstalk/bin/get-config environment | jq .NEW_RELIC_LICENSE_KEY | sed -e 's/"//g'`
  "02": 
    command: echo hostname=`/opt/elasticbeanstalk/bin/get-config environment | jq .RAILS_ENV | sed -e 's/"//g'` >> /etc/newrelic/nrsysmond.cfg 
  "03": 
    command: usermod -a -G docker newrelic
  "04": 
    command: /etc/init.d/newrelic-sysmond restart
这很好,但是将所有主机名设置为同一个名称。我不想使用Elastic Beanstalk主机名,因为每次实例扩展时,这些主机名都会更改。这就用死的实例堵塞了新的遗迹


这是运行Docker 1.6.2的64位Amazon Linux 2015.03 v1.4.3版

我找到了确定当前Elastic Beanstalk索引实例的可靠方法

"02":
  command: echo `ec2-describe-tags --filter key=Name | grep \`curl -sq http://169.254.169.254/latest/meta-data/instance-id\`` | awk '{print $5}' >> /etc/newrelic/environment-name
"03":
  command: aws elasticbeanstalk describe-environment-resources  --environment-name `cat /etc/newrelic/environment-name` --region us-east-1 | jq '.EnvironmentResources.Instances' | ruby -e "require 'json'; puts JSON.parse(ARGF.read).find_index({'Id' => '$(curl -sq http://169.254.169.254/latest/meta-data/instance-id)'})" >> /etc/newrelic/instance-index
"04": 
  command: echo hostname=`/opt/elasticbeanstalk/bin/get-config environment | jq .RAILS_ENV | sed -e 's/"//g'``cat /etc/newrelic/instance-index` >> /etc/newrelic/nrsysmond.cfg 
这个想法是:

  • 获取Elastic Beanstalk环境名称
  • 获取该环境的实例列表
  • 在该索引中查找当前实例
  • 将newrelic主机名设置为RAILS\u ENV-index

我希望这有助于其他任何人了解您使用的是哪个Elastic Beanstalk实例。

您好,我尝试了这个,但没有写入任何文件,如
/etc/newrelic/environment name
。我得到了新的空白行。我还需要配置用户/所有者/权限等其他配置吗?我想这是因为当我尝试手动配置时,权限被拒绝了
sudo echo hostname='MyApplicationQA'>/etc/newrelic/nrsysmond.cfg