Prometheus形式でメトリックを公開するためのソフトウェアのインストール
管理エージェントでは、Prometheus形式でメトリックを公開する任意の優先ソフトウェアを使用できます。
この例では、UNIXおよびLinuxカーネルの様々なハードウェアおよびカーネル関連のメトリックを公開するPrometheus Node Exporterを使用しています。Prometheus Node Exporterの詳細は、ノード・エクスポータGithubを参照してください。
VMにノード・エクスポータをインストールして実行するには、次の手順を実行します。
- Node Exporter tarファイルをダウンロードします。
wget https://github.com/prometheus/node_exporter/releases/download/v*/node_exporter-*.*-amd64.tar.gz
- ダウンロードしたファイルを解凍します。
tar xvfz node_exporter-*.*-amd64.tar.gz
- VMでノード・エクスポータを実行します。
cd node_exporter-*.*-amd64 ./node_exporter
出力は、次のようになります。INFO[0000] Starting node_exporter (version=0.16.0, branch=HEAD, revision=d42bd70f4363dced6b77d8fc311ea57b63387e4f) source="node_exporter.go:82" INFO[0000] Build context (go=go1.9.6, user=root@a67a9bc13a69, date=20180515-15:53:28) source="node_exporter.go:83" INFO[0000] Enabled collectors: source="node_exporter.go:90" INFO[0000] - boottime source="node_exporter.go:97" ... INFO[0000] Listening on :9100 source="node_exporter.go:111"
上記は、ノード・エクスポータが実行中で、デフォルト・ポート9100にメトリックを表示していることを示しています。
- ノード・エクスポータのインストールを確認します。
メトリックがエクスポートされていることを確認するには、次を使用します:
http://localhost:9100/metrics
出力は、次のようになります。
インストールを確認するもう1つの方法は、次のように、同じエンドポイントのコマンド・ラインからcurl
を実行することです。curl http://localhost:9100/metrics
出力は、次のようになります。# Output: # HELP node_cpu_seconds_total Seconds the CPUs spent in each mode. # TYPE node_cpu_seconds_total counter node_cpu_seconds_total{cpu="0",mode="idle"} 485489.29 node_cpu_seconds_total{cpu="0",mode="iowait"} 356.55 node_cpu_seconds_total{cpu="0",mode="irq"} 0.05 node_cpu_seconds_total{cpu="0",mode="nice"} 6.02 node_cpu_seconds_total{cpu="0",mode="softirq"} 1.44 node_cpu_seconds_total{cpu="0",mode="steal"} 156.66 node_cpu_seconds_total{cpu="0",mode="system"} 1241.91 node_cpu_seconds_total{cpu="0",mode="user"} 4513.21 node_cpu_seconds_total{cpu="1",mode="idle"} 485151.18 node_cpu_seconds_total{cpu="1",mode="iowait"} 485.2