13
1

More than 1 year has passed since last update.

AppDynamicsのCustom Metricでデータ収集してみたよ〜!

Posted at

:santa: 目次

  1. はじめに
  2. AppDynamicsとは?
  3. Custom Metricとは?
  4. AppDでCustom Metricの収集・可視化してみた
  5. 最後に
  6. 免責事項

:santa: はじめに

本記事はCiscoの有志による Cisco Systems Japan Advent Calendar 2020 (一枚目) の 2日目として投稿しています:christmas_tree::sparkles:
AppDynamicsのMachine AgentのCustom Metric機能でどのようなデータ連携が可能となるのかを確認してみたので、共有したいと思います。

:santa: AppDynamicsとは?

Gartner社のMagic Quadrant(APM部門)において、9年連続でリーダーに選出されているアプリケーションパフォーマンス監視ソリューションです。全ユーザー・全トランザクションを監視でき、アプリケーションのレイヤから エンドユーザーのエクスペリエンス・ビジネス情報を分析・監視することができます。

例えば、下記はドクター検索&予約アプリのAppDでの監視画面の例です。
ドクター検索 -> フォーム記入 -> 予約の各ステップでのコンバージョンレートやレスポンスタイム等を把握できるだけでなく、Intersightとの連携によるインフラ監視、ThousandEyesとの連携によるweb transaction test, HTTP server testなどの定期実行結果を同一ダッシュボードでモニタリングすることが可能です。

image.png

:santa: AppDのCustom Metricとは?

AppDynamicsでは、Machine Agentを設定した段階で Build-in Metricとして、いくつかHardware Metricが設定されており、自動的にControllerに送信されます。Custom Metricは、ユーザが自由に作成し、 Machine Agent経由でControllerに送ることができるMetricです。

公開されているExtensionもこのCustom Metricの機能を利用しています。
https://www.appdynamics.com/community/exchange/

Build-in Metric同様に、下記の機能が利用可能です。
* Automatic baselines and anomaly detection 
* Availability to display on custom dashboards
* Availability to use in policies
* Visibility of all metrics in the Metric Browser and on the Infrastructure tab (where you can display external metrics and AppDynamics metrics on the same graph)

Custom Metric の作成方法として下記3つがあります。
1. Using Script ( shell scriptを利用。簡単。) ⇦今回はこちらを利用
2. Using Java ( 複雑な処理を行う際に利用。多くのextensionはこちらを利用。)
3. Using HTTP ( HTTP requestによりAgentにデータを送信。)

詳細は、https://docs.appdynamics.com/21.6/en/infrastructure-visibility/machine-agent/extensions-and-custom-metrics をご参照ください。

:santa: Custom Metricの収集・可視化してみた

やりたいこと

  • サーバにMachine Agentをインストールし、ScriptでNSO経由で取得したデバイスデータをCustom MetricとしてController GUI上で可視化されることを確認
  • AppDの動的閾値監視がCustom Metricにも適用可能であることを確認

image.png

Custom Metric 可視化までの流れ

1. Controllerの立ち上げ

今回は、15 days Free Trial版 (SaaSのみ)を利用しました。
https://www.appdynamics.com/free-trial/

2. サーバにMachine Agentのインストール / Controllerへの接続

コントローラログイン後にGetting Started Wizardからインストーラーをダウンロードすることが可能です。
https://docs.appdynamics.com/21.3/en/application-monitoring/install-app-server-agents

ダウンロードしたインストーラーzipを監視対象のサーバー上で展開し、Machine Agentを下記の手順で起動します。
https://docs.appdynamics.com/21.3/en/infrastructure-visibility/machine-agent/start-and-stop-the-machine-agent

Linux
<machine_agent_home>/bin/machine-agent -d -p <machine_agent_home>/pidfile 

3. Custom Metricを収集するScript Fileの作成

下記のようなディレクトリ構成で、Script File(monitor_test_nso.sh)とConfiguration File(monitor.xml)を作成します。

modules
 └ CustomMonitor
    ├ monitor_test_nso.sh
    └ monitor.xml

下記の例では、NSOのRESTCONF API経由でlive-status機能を用い、ルータからCPU使用率とIFのinput/output rateを取得しています。また、実行結果がAppDで指定されたフォーマットになるように、表示調整を行っています。このフォーマットで出力できれば、中身がどんなスクリプトでもControllerで収集・可視化することができます。

monitor_test_nso.sh
#!/bin/bash

# Get CPU Utilizatioon
cpu_response=$(curl --noproxy 10.**.**.** -s -k -X "POST" "http://10.**.**.**:8080/restconf/operations/devices/device=Router1/live-status/exec/show" -H 'Content-Type: application/yang-data+xml' -H 'Accept: application/yang-data+xml' -d '<input><args>process cpu | i utilization</args></input>' -u admin:admin)
cpu_result=$(echo $cpu_response | awk '{gsub("%.*","",$14); print $14}')
printf "name=Server|Component:71853|Custom Metrics|Test|Router1|CPU Utilization,value=%d,aggregator=OBSERVATION,time-rollup=CURRENT,cluster-rollup=INDIVIDUAL\n" $cpu_result;

# Input/Output Rate
if_response=$(curl --noproxy 10.**.**.** -s -k -X "POST" "http://10.**.**.**:8080/restconf/operations/devices/device=Router1/live-status/exec/show" -H 'Content-Type: application/yang-data+xml' -H 'Accept: application/yang-data+xml' -d '<input><args>int Gi0/0/0/38 | i rate</args></input>' -u admin:admin)
input_rate=$(echo $if_response | awk '{print $13}')
output_rate=$(echo $if_response | awk '{print $21}')
printf "name=Server|Component:71853|Custom Metrics|Test|Router1|Output Rate,value=%d,aggregator=OBSERVATION,time-rollup=CURRENT,cluster-rollup=INDIVIDUAL\n" $input_rate;
sleep 1;
printf "name=Server|Component:71853|Custom Metrics|Test|Router1|Input Rate,value=%d,aggregator=OBSERVATION,time-rollup=CURRENT,cluster-rollup=INDIVIDUAL\n" $output_rate;

実行結果
# ./monitor_test_nso.sh
name=Server|Component:71853|Custom Metrics|Test|Router1|CPU Utilization,value=1,aggregator=OBSERVATION,time-rollup=CURRENT,cluster-rollup=INDIVIDUAL
name=Server|Component:71853|Custom Metrics|Test|Router1|Output Rate,value=0,aggregator=OBSERVATION,time-rollup=CURRENT,cluster-rollup=INDIVIDUAL
name=Server|Component:71853|Custom Metrics|Test|Router1|Input Rate,value=1000,aggregator=OBSERVATION,time-rollup=CURRENT,cluster-rollup=INDIVIDUAL
  • name : Custom Metricの表示先と表示名
  • value : 収集データ
  • aggregator : how the Machine Agent aggregates the values reported during a one-minute period
  • time-rollup : how the Controller rolls up the values when it converts from one-minute granularity tables to 10-minute granularity tables, and 60-minute granularity tables over time
  • cluster-rollup : how the Controller aggregates metric values in a tier (a cluster of nodes)

詳細は、https://docs.appdynamics.com/21.6/en/infrastructure-visibility/machine-agent/extensions-and-custom-metrics/build-a-monitoring-extension-using-scripts を参照ください。

4. Scriptを実行するConfiguration Fileの作成

下記は60秒ごとにmonitor_test_nso.shを定期実行し、Controllerにレポートするスクリプトです。

monitor.xml
<monitor>
    <name>TestMonitor</name>
    <type>managed</type>
    <description>Test Monitor
    </description>
    <monitor-configuration>
    </monitor-configuration>
    <monitor-run-task>
        <execution-style>periodic</execution-style>
        <execution-timeout-in-secs>120</execution-timeout-in-secs>
        <execution-frequency-in-seconds>60</execution-frequency-in-seconds>
        <name>Run</name>
        <type>executable</type>
        <task-arguments>
        </task-arguments>
        <executable-task>
            <type>file</type>
            <file>monitor_test_nso.sh</file>
        </executable-task>
    </monitor-run-task>
</monitor>

詳細は、https://docs.appdynamics.com/21.6/en/infrastructure-visibility/machine-agent/extensions-and-custom-metrics/build-a-monitoring-extension-using-scripts を参照ください。

5. Agentの再起動

Linuxの場合は、
1. "ps -ef | grep machineagent"でMachine AgentのProcess IDを確認
2. "kill "でAgent Processを停止
3. "/bin/machine-agent -d -p /pidfile"で起動

詳細は、https://docs.appdynamics.com/21.6/en/infrastructure-visibility/machine-agent/start-and-stop-the-machine-agent を参照ください。

Custom Metricに対するHealth Ruleの設定

AppDでは、指定した期間(日、週、月)ごとにベースラインを計算し、データの傾向を学習、ベースラインから指定した値以上に離れた値を検知した場合には、アラートをあげることができます。今回、Custom Metricでも同様に、ベースラインによる動的監視ができることを確認しました。

image.png

可視化

Metric Browserでの可視化

Metric Browserでは、Agentから取得した各Metricのデータをグラフで確認することができます。Custom MetricもBuild-in Metricと同様に、Metric Browserで表示されることを確認しました。

image.png

Custom Dashboardでの可視化

Custom Dashboardでは、監視が必要なMetricをピックアップし、自由に配置・配色、表示形式を選択することで独自の監視ダッシュボードを作成できます。下記はかなり簡易で作成したものですが、Custom MetricもBuild-in Metricと同様に同じダッシュボードでモニタリングできることを確認しました。

image.png

:santa: 最後に

今回は、AppDynamicsのCustom Metric機能で、Machine AgentがインストールされたサーバがNSO経由で取得したデバイスデータをController GUI上で可視化できること、動的閾値監視ができることを確認しました。実行するスクリプトの中身を変更することで、サーバで取得可能なデータであれば、何でもAppDのControllerで収集・可視化ができそうです。アプリケーションパフォーマンスだけでなく、サーバ、ルータ、スイッチなど幅広い対象、幅広いデータを同一プラットフォーム・同一ダッシュボードで監視できるというのはAppDの一つの魅力だと思いました。

現在、SaaS提供のみですが、AppDのFree Trialが可能なので、もしご興味ある方はぜひ試してみてください。
https://www.appdynamics.com/free-trial/

:santa: 免責事項

本サイトおよび対応するコメントにおいて表明される意見は、投稿者本人の個人的意見であり、シスコの意見ではありません。本サイトの内容は、情報の提供のみを目的として掲載されており、シスコや他の関係者による推奨や表明を目的としたものではありません。各利用者は、本Webサイトへの掲載により、投稿、リンクその他の方法でアップロードした全ての情報の内容に対して全責任を負い、本Web サイトの利用に関するあらゆる責任からシスコを免責することに同意したものとします。

13
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
1