Prometheus の Node Exporter は、ハードウェアおよびカーネル関連のさまざまなメトリクスを公開します。
このガイドでは、以下のことを行います。
localhost
で Node Exporter を起動するlocalhost
で Prometheus インスタンスを起動するPrometheus Node Exporter は、tarball 経由でインストールできる単一の静的バイナリです。 Prometheus の ダウンロードページ からダウンロードしたら、展開して実行します。
# NOTE: Replace the URL with one from the above mentioned "downloads" page.
# <VERSION>, <OS>, and <ARCH> are placeholders.
wget https://github.com/prometheus/node_exporter/releases/download/v<VERSION>/node_exporter-<VERSION>.<OS>-<ARCH>.tar.gz
tar xvfz node_exporter-*.*-amd64.tar.gz
cd node_exporter-*.*-amd64
./node_exporter
Node Exporter が実行され、ポート 9100 でメトリクスを公開していることを示すこのような出力が表示されるはずです。
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"
Node Exporter がインストールされて実行されたら、/metrics
エンドポイントを cURL で実行して、メトリクスがエクスポートされていることを確認できます。
curl http://localhost:9100/metrics
このような出力が表示されるはずです
# HELP go_gc_duration_seconds A summary of the GC invocation durations.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 3.8996e-05
go_gc_duration_seconds{quantile="0.25"} 4.5926e-05
go_gc_duration_seconds{quantile="0.5"} 5.846e-05
# etc.
成功しました!Node Exporter は、出力の下の方にある(node_
で始まる)さまざまなシステムメトリクスを含む、Prometheus がスクレイピングできるメトリクスを公開しています。これらのメトリクス(ヘルプとタイプ情報を含む)を表示するには
curl http://localhost:9100/metrics | grep "node_"
ローカルで実行されている Prometheus インスタンスは、Node Exporter メトリクスにアクセスできるように適切に設定する必要があります。次の prometheus.yml
設定ファイルの例は、Prometheus インスタンスに localhost:9100
経由で Node Exporter からスクレイピングする方法と頻度を指示します。
global:
scrape_interval: 15s
scrape_configs:
- job_name: node
static_configs:
- targets: ['localhost:9100']
Prometheus をインストールするには、プラットフォーム用の 最新リリースをダウンロードし、展開します。
wget https://github.com/prometheus/prometheus/releases/download/v*/prometheus-*.*-amd64.tar.gz
tar xvf prometheus-*.*-amd64.tar.gz
cd prometheus-*.*
Prometheus をインストールしたら、--config.file
フラグを使用して、上記で作成した Prometheus 設定を指すようにして起動できます。
./prometheus --config.file=./prometheus.yml
Prometheus が実行中の Node Exporter インスタンスからメトリクスをスクレイピングするようになったので、Prometheus UI (別名 式ブラウザ) を使用してこれらのメトリクスを調べることができます。ブラウザで localhost:9090/graph
に移動し、ページ上部のメイン式バーを使用して式を入力します。式バーは次のようになります
Node Exporter に固有のメトリクスには node_
というプレフィックスが付いており、node_cpu_seconds_total
や node_exporter_build_info
などのメトリクスが含まれています。
以下のリンクをクリックして、メトリクスの例をご覧ください。
メトリクス | 意味 |
---|---|
rate(node_cpu_seconds_total{mode="system"}[1m]) |
過去 1 分間における、システムモードで費やされた CPU 時間の平均量 (秒単位) |
node_filesystem_avail_bytes |
非ルートユーザーが使用できるファイルシステム領域 (バイト単位) |
rate(node_network_receive_bytes_total[1m]) |
過去 1 分間における、1 秒あたりの平均ネットワーク受信トラフィック (バイト単位) |
このドキュメントは オープンソースです。問題やプルリクエストを提出して改善にご協力ください。