Individual sitting in a chair working on their laptop with layered graphics in the background

概要

本ブログでは、ファーストステップガイドとして New Relic Infrastructure エージェントのインストール方法をご紹介いたします。
具体的な導入方法をお知りになりたい方、実施前に導入作業の流れなどをご確認されたい方はご参照ください。
内容をいただき、作業端末やテスト環境などで導入テストをお試しください。

また、New Relic アカウントをお持ちでない場合は これからはじめるNew Relicライフ! 無料でアカウントを開設しよう! をご覧ください。

New Relic Infrastructure とは

New Relic Infrastructure は 軽量の実行ファイルである Infrastructure エージェントをサーバサイドで稼働させることで定期的に OS, ミドルウェア, Network などのパフォーマンス情報、ログや OS パッケージ情報を収集します。
CPU, Memory, Network, Storage の値はもちろん、プロセス毎のリソース利用状況も収集しプリセットの UI からカスタマイズなしで可視化することができます。
ミドルウェアについても MySQL, NGINX, Cassandra, Kafka などの一般的な製品やサービスに対応したオンホストインテグレーションにて構成されたメトリクスでの情報収集と UI でのデータ閲覧が可能です。また Flex プラグインを利用することで、任意のコマンドでの情報収集を追加することも可能です。

また、クラウドインテグレーションを行うことで、パブリッククラウドのモニタリング情報を連携することができます。New Relic APM や Browser などの情報と合わせて、基盤、インフラ、アプリなどシステムに関する情報をシームレスに確認することができるようになります。
さらにインベントリ機能では、全サーバのパッケージ情報を横断的に閲覧、検索することができ、更新作業などの変更情報は、イベントに記録されます。インフラ管理にもご活用いただけます。

導入の流れ

New Relic Infrastructure は、主要な Linux Distribution, Windows, MacOS などのメジャー OS、アークテクチャに対応しており Infrastructure エージェントをインストールすることで、標準的なメトリクスを定期的に収集します。
インストール方法には、インストールスクリプトで行うガイドインストールや手動で行う方法、Docker コンテナとして稼働させる方法、または Ansible や Chef などの管理ツールを用いる方法があります。
最も簡易的なインストール方法は、ガイドインストールで、コマンド1つでインストールを行うことができます。
また、Infrastructure エージェントは収集したデータを New Relic 送信するので、特定のドメインやポートへの送信アクセス権限が必要となります。お使いのシステムに制限がある場合は、設定変更、プロキシのご利用にてご対応ください。
 

インストールの実施例

ここでは下記の環境へのガイドインストールによる Infrastructure エージェントの導入方法をご紹介します。

  • Linux (RHEL9)
  • Windows
  • Docker

Step 1: インストールランチャページへ

New Relic platform にログインし、Infrastructure ページに遷移します。
Infrastructure が導入されていない場合は 下記のように導入を促す内容が表示されます。
中央の "Try new experience" -> "Instrument your hosts" からインストールランチャページに遷移します。
また、すでにインストールされたホストが存在する場合は、左ペインの "+Add data" からインストールランチャページに遷移します。

 

Step 2: Infrastructure エージェントを選択

Add Data ページに遷移後、"Infrastructure & OS” を選択し、”New Relic Infrastructure agent” を選択します。

Step 3: 環境を選択

インストール対象の選択画面が表示されるので、ターゲット環境に合わせて選択します。

Step 4: インストール処理の案内表示

OS 選択後、インストールプロセスの内容が表示されます。
Linux, Windows, macOS では、ログやインストールソフトウェアに応じたインテグレーションが自動検出され、合わせて導入される旨の案内が表示されます。

Step 5: インストールコマンドの実行

Linux でのインストール

ディストリビューションの違いはなく、共通コマンドでインストールを行うことができます。
install.sh ファイルを curl コマンドで取得し、実行します。その後、newrelic コマンドで infrastructure エージェントをインストールします。
また、Customize your installation では、HTTPS_PROXY などの変数をコマンドに加えることができます。

 

sudo 権限を持つユーザーにて、コマンドを実行し、インストールを行います。

[~]$ curl -Ls https://download.newrelic.com/install/newrelic-cli/scripts/install.sh | bash && sudo NEW_RELIC_API_KEY=NRAK-*************************** NEW_RELIC_ACCOUNT_ID=******* /usr/local/bin/newrelic install
Installing New Relic CLI v0.68.18
Installing to /usr/local/bin using sudo

 _   _                 ____      _ _
| \ | | _____      __ |  _ \ ___| (_) ___
|  \| |/ _ \ \ /\ / / | |_) / _ | | |/ __|
| |\  |  __/\ V  V /  |  _ |  __| | | (__
|_| \_|\___| \_/\_/   |_| \_\___|_|_|\___|

Welcome to New Relic. Let's set up full stack observability for your environment.
Our Data Privacy Notice: https://newrelic.com/termsandconditions/services-notices

✔ Connecting to New Relic Platform
   Connected


Installing New Relic

==> Installing Infrastructure Agent
Running agent status check attempt...
Agent status check ok.
Infra key: i-03db97ba9acfc3749
✔ Installing Infrastructure Agent
   Installed

==> Installing Logs Integration
✔ Installing Logs Integration
   Installed

We've detected additional monitoring that can be configured by installing the following:
  Golden Signal Alerts
  Apache Integration
  MySQL Integration
  PHP Agent
  PostgreSQL Integration

? Continue installing?  (Y/n)

コマンドを実行すると上記のように、Infrastructure Agent と Logs Integration がインストールされました。
さらに自動検出にて、検出されたインテグレーションを導入するかを聞かれます。
インストールする場合は Y を押下します。追加のインストールが不要な場合は、n で終了します。
各項目のインストールプロセスにて、個別でインストールの有無を聞かれるので、不要な項目のみ飛ばすことができます。

また、項目によっては追加の情報方を求められます。
たとえば MySQL Integration では、情報収集に利用する DB ユーザとそのパスワードの入力を求められます。

==> Installing MySQL Integration
MySql credential with permission to create user, and grant select/replication permission is required, please enter it below when prompted

Please enter your username for MySql (default: root):
Enter password:

サーバのスペックや負荷状況、追加入力の内容にもよりますが、全インテグレーション含めて、10分程度で完了しました。
ログと infrastructure エージェントのみだと 3分程度でした。

 New Relic installation complete

  --------------------
  Installation Summary

  ✔  Golden Signal Alerts  (installed)
  ✔  Apache Integration  (installed)
  ✔  Infrastructure Agent  (installed)
  ✔  Logs Integration  (installed)
  ✔  MySQL Integration  (installed)
  ✔  PHP Agent  (installed)
  ✔  PostgreSQL Integration  (installed)

  View your data at the link below:
  ⮕  https://onenr.io/0kjnE6Ml9Ro

  View your logs at the link below:
  ⮕  https://onenr.io/0LwGgXyeew6

  --------------------

インストール後は newrelic-infra.service がデーモン起動され、情報収集が開始されます。また、自動起動も有効で設定されます。

 [~]$ sudo systemctl is-enabled newrelic-infra.service
enabled

インストールプロセスに合わせてブラウザ表示も連動し、インストール結果が表示されます。同環境は AWS 常にあるため、さらに AWS 連携を行うかを聞かれていますが、本ブログではスキップします。

“See your data” をクリックすると、収集したデータを閲覧することができます。

 

Windows でのインストール

powershell のコマンドが表示されます。install.ps1 ファイルを WebClient.DownloadFile メソッドで 取得し、実行します。その後、newrelic.exe コマンドで infrastructure エージェントをインストールします。
また、Customize your installation では、HTTPS_PROXY などの変数をコマンドに加えることができます。

1st-step-guide infrastructure windows command

管理者権限にて、powershell を起動し、コマンドを実行し、インストールを行います。
同環境では、他のインテグレーションサービスが存在しなかったため、所要時間は 3分程度で完了しました。

PS C:\Users\TEMP> [Net.ServicePointManager]::SecurityProtocol = 'tls12, tls'; $WebClient = New-Object System.Net.WebClient; $WebClient.DownloadFile("https://download.newrelic.com/install/newrelic-cli/scripts/install.ps1", "$env:TEMP\install.ps1"); & PowerShell.exe -ExecutionPolicy Bypass -File $env:TEMP\install.ps1;   $env:NEW_RELIC_API_KEY='NRAK-***************************'; $env:NEW_RELIC_ACCOUNT_ID='*******'; & 'C:\Program Files\New Relic\New Relic CLI\newrelic.exe' install
 _   _                 ____      _ _
| \ | | _____      __ |  _ \ ___| (_) ___
|  \| |/ _ \ \ /\ / / | |_) / _ | | |/ __|
| |\  |  __/\ V  V /  |  _ |  __| | | (__
|_| \_|\___| \_/\_/   |_| \_\___|_|_|\___|

Welcome to New Relic. Let's set up full stack observability for your environment.
Our Data Privacy Notice: https://newrelic.com/termsandconditions/services-notices

✔ Connecting to New Relic Platform
   Connected


Installing New Relic

==> Installing Infrastructure Agent
New Relic infrastructure agent for Windows installed and started
Agent status check ok.
Infra key: i-043068dd46ae75137
✔ Installing Infrastructure Agent
   Installed

==> Installing Logs Integration
✔ Installing Logs Integration
   Installed

  New Relic installation complete

  --------------------
  Installation Summary

  ✔  Infrastructure Agent  (installed)
  ✔  Logs Integration  (installed)

  View your data at the link below:
  ⮕  https://onenr.io/01wZvg6mXw6

  View your logs at the link below:
  ⮕  https://onenr.io/0Bj3LYp5vQX

  --------------------

PS C:\Users\TEMP>

インストール後は New Relic Infrastructure Agent サービスが起動し、情報収集が開始されます。また、自動起動も有効で設定されます。

インストールプロセスに合わせてブラウザ表示も連動し、インストール結果が表示されます。
同環境は AWS 常にあるため、さらに AWS 連携を行うかを聞かれていますが、本ブログではスキップします。
“See your data” をクリックすると、収集したデータを閲覧することができます。

 

Docker としてインストール

docker run コマンドが必要なオプションとともに表示されます。各オプションの詳細はドキュメントをご参照ください。
本ブログでは Linux ホストにインフラエージェント用の Docker コンテナを稼働させます。
Docker コンテナで稼働する Infrastructure エージェントを介して、ホストとコンテナのパフォーマンス情報を収集することができます。
なお、事前に docker の稼働環境を整えておく必要がございます。

docker 稼働に必要な権限を持つユーザーにて、コンテナの起動を実施するとホストの情報収集が開始されます。
サーバのスペックや負荷状況などによりますが、1分程度で完了しました。

[~]$ sudo docker run \
-d \
--name newrelic-infra \
--network=host \
--cap-add=SYS_PTRACE \
--privileged \
--pid=host \
-v "/:/host:ro" \
-v "/var/run/docker.sock:/var/run/docker.sock" \
-e NRIA_LICENSE_KEY=**************************************** \
newrelic/infrastructure:latest
Unable to find image 'newrelic/infrastructure:latest' locally
latest: Pulling from newrelic/infrastructure
31e352740f53: Pull complete
2b17cadf5b0e: Pull complete
efcc5f836f57: Pull complete
1e1182e1269f: Pull complete
8127aa172505: Pull complete
f1aa556750eb: Pull complete
d39cf399b3fa: Pull complete
2989426ea636: Pull complete
6610201c2af8: Pull complete
3a9278b9a481: Pull complete
Digest: sha256:7b7d472bce5aa115a469f14f693f422156d3e6dddd74fed9c7704bfcceac42aa
Status: Downloaded newer image for newrelic/infrastructure:latest
d87c5d7d0df435e30602312d1c95a31163dcbeec0c4aade158c7fbec5cc1aed0
[~]$
[~]$ sudo docker ps -a
CONTAINER ID   IMAGE                            COMMAND                  CREATED          STATUS          PORTS     NAMES
d87c5d7d0df4   newrelic/infrastructure:latest   "/sbin/tini -- /usr/…"   31 seconds ago   Up 30 seconds             newrelic-infra
[~]$

ブラウザとは連動しませんが、下部の “Check your connection” をクリックすると “See your data” に変化し、収集したデータを閲覧することができます。

Step 6: データの確認

取得したデータは、Infrastructure > Hosts などから確認できます。Summary の各ホスト名からは個別の情報を確認することができます。
データが届かないなどの場合は、ドキュメントのインフラストラクチャのトラブルシューティングをご確認ください。

おわりに

本ブログでは Linux (RHEL), Windows または Docker での New Relic Infrastructure エージェントをガイドインストールにて導入する方法をご紹介いたしました。
オンホストインテグレーションやクラウドインテグレーションなど紹介しきれなったものもございます。
ご興味をもっていただけましたら、他のブログやドキュメントもご参照ください。

New Relic Infrastructure は、インフラ監視、管理に利用できる強力なツールの 1つです。
そしてフロントエンド(Browser, Mobile)、アプリケーション (APM) やネットワーク (NPM) と合わせて、サービス全体のオブザーバビリティを達成するための一角です。
Infrastructure エージェントの導入を行い、New Relic Infrastructure をご活用ください。