TL;DR
Raspberry pi zero w にはnode-exporterでデフォルトで有効になっている監視対象が設定されていない
このため、syslogにcollector取得のエラーが出力され続ける
node-expoter起動時に--no-collector.pressure --no-collector.rapl
を追加することでエラーは出力されなくなる
背景
以前より、自宅環境のRspberry pi zero w上にPrometheusのnode-exporterをインストールし、リソース監視を実施していた
Grafana Lokiにてsyslogを確認していたところ、syslogに下記エラーが定期的に出力されていた
Jan 17 22:47:47 raspberry-zw prometheus-node-exporter[27206]: level=error ts=2023-01-17T13:47:47.285Z caller=collector.go:161 msg="collector failed" name=rapl duration_seconds=0.000263998 err="failed to retrieve rapl stats: no sysfs powercap / RAPL power metrics files found"
Jan 17 22:47:47 raspberry-zw prometheus-node-exporter[27206]: level=error ts=2023-01-17T13:47:47.359Z caller=collector.go:161 msg="collector failed" name=pressure duration_seconds=0.000376998 err="failed to retrieve pressure stats: psi_stats: unavailable for cpu"
環境
実行環境はRaspiberry pi zero w、OSはRasbian 11 bullseye
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
node-exporterはapt経由でインストールしたもの
rapl回りのバグがver 1.1.2でfixされていたようだが、今回は無関係
node_exporter, version 1.1.2+ds (branch: debian/sid, revision: 1.1.2+ds-2.1)
build user: team+pkg-go@tracker.debian.org
build date: 20210725-21:22:06
go version: go1.15.9
platform: linux/arm
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-===================================-=======================-============-====================================================================
ii prometheus-node-exporter 1.1.2+ds-2.1 armhf Prometheus exporter for machine metrics
ii prometheus-node-exporter-collectors 0+git20210115.7d89f19-1 all Supplemental textfile collector scripts for Prometheus node_exporter
公式ドキュメントの記載
公式ドキュメント:https://github.com/prometheus/node_exporter/blob/master/README.md
によると下記とのこと
要するに実行するメトリックはデフォルト設定で自動的に有効化されて実行される
これを無効化したい場合は--no-collector.<name>
を起動パラメタに指定せよとのこと
Collectors
There is varying support for collectors on each operating system. The tables below list all existing collectors and the supported systems.Collectors are enabled by providing a --collector. flag. Collectors that are > enabled by default can be disabled by providing a --no-collector. flag. To >enable only some specific collector(s), use --collector.disable-defaults --collector. ....
今回エラーとして出力されていたのは下記の2つのcollector
Name Description pressure Exposes pressure stall statistics from /proc/pressure/. rapl Exposes various statistics from /sys/class/powercap.
原因
そもそも、collectorの参照先のpsi/raplがraspberry pi zero wにはインストールされていない
(Raspiberrypi 4では当該のディレクトリは存在し、node expoterをデフォルトで実行しても今回のエラーは出力されない)
ls: cannot access '/proc/pressure': No such file or directory
ls: cannot access '/sys/class/powercap': No such file or directory
対応
公式ドキュメントに合った通り、起動パラメタに--no-collector.<name>
を設定する
今回はsystemctlのサービスファイル/lib/systemd/system/prometheus-node-exporter.service
の中で、コマンド実行時の環境変数ファイルが指定されているため、
環境設定ファイルを上書きする
[Unit]
Description=Prometheus exporter for machine metrics
Documentation=https://github.com/prometheus/node_exporter
[Service]
Restart=on-failure
User=prometheus
EnvironmentFile=/etc/default/prometheus-node-exporter
ExecStart=/usr/bin/prometheus-node-exporter $ARGS
ExecReload=/bin/kill -HUP $MAINPID
TimeoutStopSec=20s
SendSIGKILL=no
[Install]
WantedBy=multi-user.target
変更前:
# Set the command-line arguments to pass to the server.
# Due to shell scaping, to pass backslashes for regexes, you need to double
# them (\\d for \d). If running under systemd, you need to double them again
# (\\\\d to mean \d), and escape newlines too.
ARGS=""
# prometheus-node-exporter supports the following options:
#
# --collector.arp
# Enable the arp collector (default: enabled).
変更後:
# Set the command-line arguments to pass to the server.
# Due to shell scaping, to pass backslashes for regexes, you need to double
# them (\\d for \d). If running under systemd, you need to double them again
# (\\\\d to mean \d), and escape newlines too.
ARGS="--no-collector.pressure --no-collector.rapl"
# prometheus-node-exporter supports the following options:
#
# --collector.arp
# Enable the arp collector (default: enabled).
変更適用コマンド
下記を実行して、変更を適用する
$ sudo vim /etc/default/prometheus-node-exporter
$ sudo systemctl restart prometheus-node-exporter
% sudo systemctl status prometheus-node-exporter
● prometheus-node-exporter.service - Prometheus exporter for machine metrics
Loaded: loaded (/lib/systemd/system/prometheus-node-exporter.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2023-01-17 23:13:22 JST; 55min ago
Docs: https://github.com/prometheus/node_exporter
Main PID: 27402 (prometheus-node)
Tasks: 7 (limit: 415)
CPU: 2min 21.207s
CGroup: /system.slice/prometheus-node-exporter.service
└─27402 /usr/bin/prometheus-node-exporter --no-collector.pressure --no-collector.rapl
以上