toto_1212

技術のログをツラツラ書きます。自分用ですが参考にしていただけたら嬉しいです。間違ってたらドンドン突っ込んでください。

【Update】New Relicで監視

2年以上前にNew Relicで監視という記事を書きましたが、UIが大幅に変更になっているのとDockerコンテナを監視できる機能が追加されているので情報を更新します。

アカウントは作成済みとします。

1. 上部もしくは中央の「SERVERS」をクリックする

f:id:toatoshi:20151007105712j:plain

2. プラットフォームを選択する

※今回はCentOS7にて実施
f:id:toatoshi:20151007105801j:plain

3. ページ下部に進むと導入方法が表示されるので対象サーバ上で実施する

f:id:toatoshi:20151007105834j:plain

3-1. リポジトリ導入

$ rpm -Uvh http://download.newrelic.com/pub/newrelic/el5/i386/newrelic-repo-5-3.noarch.rpm
Retrieving http://download.newrelic.com/pub/newrelic/el5/i386/newrelic-repo-5-3.noarch.rpm
warning: /var/tmp/rpm-tmp.LemJ0K: Header V3 DSA/SHA1 Signature, key ID 548c16bf: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:newrelic-repo-5-3                ################################# [100%]

3-2. newrelic-sysmondパッケージ導入

$ yum install newrelic-sysmond
Loaded plugins: fastestmirror
base                                                                                                                                                       | 3.6 kB  00:00:00
extras                                                                                                                                                     | 3.4 kB  00:00:00
newrelic                                                                                                                                                   |  951 B  00:00:00
openlogic                                                                                                                                                  | 1.3 kB  00:00:00
updates                                                                                                                                                    | 3.4 kB  00:00:00
newrelic/x86_64/primary                                                                                                                                    |  10 kB  00:00:01
Loading mirror speeds from cached hostfile
newrelic                                                                                                                                                                    85/85
Resolving Dependencies
--> Running transaction check
---> Package newrelic-sysmond.x86_64 0:2.2.0.125-1 will be installed
--> Finished Dependency Resolution

Resolving Dependencies
--> Running transaction check
---> Package newrelic-sysmond.x86_64 0:2.2.0.125-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================================
 Package                                         Arch                                  Version                                      Repository                               Size
==================================================================================================================================================================================
Installing:
 newrelic-sysmond                                x86_64                                2.2.0.125-1                                  newrelic                                1.9 M

Transaction Summary
==================================================================================================================================================================================
Install  1 Package


Total download size: 1.9 M
Installed size: 4.6 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/newrelic/packages/newrelic-sysmond-2.2.0.125-1.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 548c16bf: NOKEY] 158 kB/s | 1.9 MB  00:00:00 ETA
Public key for newrelic-sysmond-2.2.0.125-1.x86_64.rpm is not installed
newrelic-sysmond-2.2.0.125-1.x86_64.rpm                                                                                                                    | 1.9 MB  00:00:12
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-NewRelic
Importing GPG key 0x548C16BF:
 Userid     : "New Relic <support@newrelic.com>"
 Fingerprint: b60a 3ec9 bc01 3b9c 2379 0ec8 b31b 29e5 548c 16bf
 Package    : newrelic-repo-5-3.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-NewRelic
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : newrelic-sysmond-2.2.0.125-1.x86_64                                                                                                                            1/1
  Verifying  : newrelic-sysmond-2.2.0.125-1.x86_64                                                                                                                            1/1

Installed:
  newrelic-sysmond.x86_64 0:2.2.0.125-1

Complete!
4. ライセンスキー導入

右上部のアカウントをクリックし、「Account settings」をクリックする。
f:id:toatoshi:20151007110006j:plain
f:id:toatoshi:20151007110026j:plain

表示されたページの右に「License key」が表示されているので文字列を控える。

表示された文字列を入れてコマンド実行
nrsysmond-config --set license_key=****************************************
※ *******はLicense keyの文字列
5. newrelic-sysmond サービスを起動する
$ systemctl start newrelic-sysmond

RHEL6以下だと、、、
/etc/init.d/newrelic-sysmond start
監視画面

SERVERSをクリックし、対象サーバのホスト名をクリックする。
f:id:toatoshi:20151007110355j:plain

Overview
f:id:toatoshi:20151007110424j:plain

Processes
f:id:toatoshi:20151007110438j:plain

Network
f:id:toatoshi:20151007110452j:plain

Disks
f:id:toatoshi:20151007110507j:plain

Dockerコンテナ監視手順

手順は「Enabling New Relic Servers for Docker」に載っています。
※Dockerコンテナ上のOSには何もする必要はありません。

1.Install and configure Docker

2.Install New Relic Servers for Linux on your Docker server, NOT on your Docker container.

3.If a docker group doesn't already exist, create a new group named docker:

groupadd -r docker

4.Add the newrelic user to the docker group with a command similar to:

usermod -a -G docker newrelic

5.Restart Docker.

6.Restart the New Relic Servers for Linux agent.

New Relic Agentが導入されている環境にDocker監視用の設定を入れても監視できました。
ただ、ページ下部にも書いてあるように古いLinuxに関しては、/etc/newrelic/nrsysmond.cfgに
cgroup_root="/sys/fs/cgroup"を入れないと監視されないようです。

既に運用しているDocker環境がある場合は、Dockerサービスの再起動を伴いますので注意が必要です。