目的
GlusterFSの各種メトリクスをPrometheus形式に変換するExporterがありますので、それを使ってメトリクスを可視化してみます。表示先はIBM Cloud Monitoring with Sysdigを使用します。Sysdigは最近Prometheus形式に対応しました。
環境
過去記事で構築した環境を前提とします。
手順
Gluster Exporter
gluster-exporterのビルド
Goでビルドします。
$ mkdir -p ${GOPATH}/src/github.com/gluster
$ cd ${GOPATH}/src/github.com/gluster
$ git clone https://github.com/gluster/gluster-prometheus.git
$ cd gluster-prometheus
$ ./scripts/install-reqs.sh
$ make
$ ./build/gluster-exporter --version
version : v0.3-dev.93.git3ebaacc
go version: go1.15.14
go OS/arch: linux/amd64
gluster-exporterのインストール
下記2つのファイルをGlusterFSサーバ(全台)にコピーします。
./build/gluster-exporter.service -> /etc/systemd/system/
./build/gluster-exporter -> /usr/local/sbin/
構成ファイルの作成
下記ファイルをGlusterFSサーバ(全台)に配置します。
[globals]
gluster-mgmt = "glusterd"
glusterd-dir = "/var/lib/glusterd"
gluster-binary-path = "gluster"
# If you want to connect to a remote gd1 host, set the variable gd1-remote-host
# However, using a remote host restrict the gluster cli to read-only commands
# The following collectors won't work in remote mode : gluster_volume_counts, gluster_volume_profile
# gd1-remote-host = "localhost"
gd2-rest-endpoint = "http://127.0.0.1:24007"
port = 9713
metrics-path = "/metrics"
log-dir = "/var/log"
log-file = "gluster-exporter.log"
log-level = "info"
[collectors.gluster_ps]
name = "gluster_ps"
sync-interval = 5
disabled = false
[collectors.gluster_brick]
name = "gluster_brick"
sync-interval = 5
disabled = false
サービス開始
GlusterFSサーバ(全台)でGluster Exporterを開始します。
# systemctl daemon-reload
# systemctl enable --now gluster-exporter
動作確認
GlusterFSサーバの外からポート9713にアクセスします。
$ curl -s vs-gluster-tok1:9713/metrics
$ curl -s vs-gluster-tok2:9713/metrics
$ curl -s vs-gluster-tok3:9713/metrics
Sysdig
Sysdig Agentのインストール
ガイドに従い、GlusterFSサーバ(全台)にインストールします。
$ curl -sL https://ibm.biz/install-sysdig-agent | sudo bash -s -- -a ******** -c ingest.private.jp-tok.monitoring.cloud.ibm.com --collector_port 6443 --secure true -ac "sysdig_capture_enabled: false"
Prometheusスクレイピングの有効化
3台共通で、Sysdig AgentからPrometheusのスクレイピングを有効化します。
(追記)
prometheus:
enabled: true
prom_service_discovery: true
スクレイピングの設定は各サーバでそれぞれtargetsを自ホストにします。Sysdig AgentとGlusterFSを1:1で対応させたいためです。
scrape_configs:
- job_name: gluster
static_configs:
- targets:
- vs-gluster-tok1:9713
scrape_configs:
- job_name: gluster
static_configs:
- targets:
- vs-gluster-tok2:9713
scrape_configs:
- job_name: gluster
static_configs:
- targets:
- vs-gluster-tok3:9713
各サーバでSysdig Agentを再起動します。
# service dragent restart
ダッシュボードの表示確認
スクレイプ開始から数分~10分程度経つと、Sysdigのダッシュボードで表示できるようになります。
生Prometheusだとスクレイプ開始後すぐに結果が確認できるのですが、Sysdigはかなり時間がかかります。とても不満な点です。