DatadogのフリートライアルでLive Process Monitoringを試してみる

DatadogのLive Process Monitoring機能を使用してプロセスの状況(CPU使用率など)をEC2インスタンス外から確認してみました。
2018.10.15

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

はじめに

おはようございます、加藤です。
EC2インスタンスのCPU使用率などが高い時に原因特定の為に、インスタンス内に入ってtopコマンドを使って何が原因か調べたりすることがあると思います。
とはいえ、なにかある度に毎回インスタンス内に入る...というのは手間です。
そこでDatadogのLive Process Monitoring機能を使って外部からプロセス一覧と負荷を可視化してみました。
検証はトライアルのラインセンスを使って行っています。

Dataogのトライアルは14日間、全ての機能を使用可能です。Live Process Monitoringを利用するには、Enterpriseライセンスが必要なので購入を検討する際はご注意ください。

やってみた

アカウント発行

トライアルページ(https://app.datadoghq.com/signup)からアカウントを発行します。

アンケートを求められるので回答します。

エージェントのインストール

今回、監視したい対象はAmazon Linux 2です。
Amazon Linuxとしか記載がありませんが、easy one-step installのコマンドを使用してインストールしてみます。

OSにログインしてコマンドを実行します。

$ DD_API_KEY=**************************** bash -c "$(curl -L https://raw.githubusercontent.com/DataDog/datadog-agent/master/cmd/agent/install_script.sh)"

Complete!と表示されればOKです。

Installed:
  datadog-agent.x86_64 1:6.5.2-1

Complete!

* Adding your API key to the Agent configuration: /etc/datadog-agent/datadog.yaml

* Starting the Agent...



Your Agent is running and functioning properly. It will continue to run in the
background and submit metrics to Datadog.

If you ever want to stop the Agent, run:

    sudo systemctl stop datadog-agent

And to run it again run:

    sudo systemctl start datadog-agent

Live Process Monitoring はデフォルトでは無効です、有効に変更します。
YAML形式のコンフィグファイルが下記のような変更を追記します。

process_config:
  enabled: "true"

コンフィグファイルをエディタで開きます。

$ sudo vim /etc/datadog-agent/datadog.yaml

コメントアウトされている状態なので、下記のdiff情報を参考にコメントインするか追記します。

--- /etc/datadog-agent/datadog.yaml.example     2018-09-19 17:02:30.000000000 +0000
+++ /etc/datadog-agent/datadog.yaml     2018-10-15 04:42:33.573762659 +0000
@@ -544,12 +544,12 @@

 # Process agent specific settings
 #
-# process_config:
+process_config:
 #   A string indicating the enabled state of the Process Agent.
 #   If "false" (the default) it will only collect containers.
 #   If "true" it will collect containers and processes.
 #   If "disabled" it will be disabled altogether and won't start.
-#   enabled: "true"
+  enabled: "true"
 #   The full path to the file where process-agent logs will be written.
 #   log_file:
 #   The interval, in seconds, at which we will run each check. If you want consistent

最後にエージェントを再起動して、OS側の作業は終了です。

$ sudo systemctl restart datadog-agent

ブラウザに戻り、次に進みます。

Live Process Monitoringを試してみる

プロセス画面(Infrastructure → Processes)を開きます。

プロセス一覧が確認できました!
インスタンス無いでstressという負荷試験ツールを実行しています。CPU使用率においてこのstressが支配的であることを確認できます。

Dashboardに追加することで、常にCPU使用率を見ることもできました。

あとがき

簡単にインストールからプロセス状況の可視化が行えました。自分で何かスクリプトを書いたり面倒な設定無しに実現できるのは素晴らしいですね!