Amazon Web Services (AWS) Elastic Beanstalk は、アプリケーションの簡単なデプロイメントとスケーラビリティを可能にするダイナミックなサービスです。以下の手順で、インフラストラクチャエージェントを、AWS Elastic Beanstalkアプリケーションで起動したインスタンスにデプロイします。
インフラストラクチャエージェントのデプロイに加えて、New RelicとAWSを統合し、Elastic Beanstalkの監視情報をNew Relicに取り込むこともできます。まだ行っていない場合は、 Amazon インテグレーションとインフラストラクチャ モニタリング の指示に従ってください。
要件
サポートされている Amazon Web Services のアカウントを持っていることを確認してください 。また、New Relic のインストールには、 New Relic のライセンスキー が必要です。これは、 アカウントのサインアップ の際に New Relic が提供する 40 文字の 16 進数の文字列です。
Infrastructureエージェントをインストールする
AWS Elastic Beanstalkで起動したインスタンスにインフラストラクチャエージェントをインストールするには、以下の手順に従います。
Elastic BeanStalkアプリケーション内の.ebextensions
フォルダーに、 newrelic.config
という名前の新しいファイルを作成します。
オペレーティングシステムに基づいて、次のコンテンツをファイルに追加し、 YOUR_LICENSE_KEY
をNewRelicライセンスキーに置き換えます。
files:
"/etc/newrelic-infra.yml" :
mode: "000644"
owner: root
group: root
content: |
license_key: YOUR_LICENSE_KEY
commands:
# Create the agent’s yum repository
"01-agent-repository":
command: sudo curl -o /etc/yum.repos.d/newrelic-infra.repo https://download.newrelic.com/infrastructure_agent/linux/yum/el/6/x86_64/newrelic-infra.repo
#
# Update your yum cache
"02-update-yum-cache":
command: yum -q makecache -y --disablerepo='*' --enablerepo='newrelic-infra'
#
# Run the installation script
"03-run-installation-script":
command: sudo yum install newrelic-infra -y
files:
"/etc/newrelic-infra.yml" :
mode: "000644"
owner: root
group: root
content: |
license_key: YOUR_LICENSE_KEY
commands:
# Create the agent’s yum repository
"01-agent-repository":
command: sudo curl -o /etc/yum.repos.d/newrelic-infra.repo https://download.newrelic.com/infrastructure_agent/linux/yum/amazonlinux/2/x86_64/newrelic-infra.repo
#
# Update your yum cache
"02-update-yum-cache":
command: yum -q makecache -y --disablerepo='*' --enablerepo='newrelic-infra'
#
# Run the installation script
"03-run-installation-script":
command: sudo yum install newrelic-infra -y
packages:
msi:
infrastructure: https://download.newrelic.com/infrastructure_agent/windows/newrelic-infra.msi
files:
"C:\\Program Files\\New Relic\\newrelic-infra\\newrelic-infra.yml":
content: |
license_key: YOUR_LICENSE_KEY
commands:
01_stop-newrelic-infra:
command: net stop newrelic-infra
ignoreErrors: true
02_start-newrelic-infra:
command: net start newrelic-infra
ignoreErrors: true
作成したアプリをElastic BeanStalkにプッシュします。
- 通常、
eb deploy
を使用します。 - まだEbCLI2.6を使用している場合は、必要に応じて
git aws.push
を使用してください。 - オプションです。AWS コンソール UI を使用します。
セットアップが成功した後、New Relic に測定値が表示され始めるまでに 15 分ほどかかることがあります。ホストのインフラストラクチャーページは one.newrelic.com で確認できます。
インフラストラクチャ・エージェントのアンインストール
エージェントをアンインストールするには、次の構成で.ebextensions
}からnewrelic.config
を更新してから、デプロイメントを更新します。
# Remove agent configuration file
"04-agent-remove-config":
command: sudo rm /etc/newrelic-infra.yml
command: sudo yum remove newrelic-infra -y
03_uninstall-newrelic-infra:
command: wmic product where name="New Relic Infrastructure Agent" call uninstall