systemctl を使用して Prometheus または Blackbox エクスポートを実行することはできません。

systemctl を使用して Prometheus または Blackbox エクスポートを実行することはできません。

以下の手順に従ってPrometheus Blackbox Importerをインストールしました。https://devconnected.com/how-to-install-and-configure-blackbox-exporter-for-prometheus/

コマンドラインからブラックボックスのエクスポートを開始すると正常に動作します。

/usr/local/bin/blackbox_exporter --config.file=/etc/blackbox/blackbox.yml --web.listen-address=":9115"
level=info ts=2023-05-09T15:18:12.170335169Z caller=main.go:213 msg="Starting blackbox_exporter" version="(version=0.14.0, branch=HEAD, revision=bba7ef76193948a333a5868a1ab38b864f7d968a)"
level=info ts=2023-05-09T15:18:12.17114947Z caller=main.go:226 msg="Loaded config file"
level=info ts=2023-05-09T15:18:12.171355458Z caller=main.go:330 msg="Listening on address" address=:9115

サービスとして実行しようとすると、次のことは発生しません。

systemctl status blackbox_exporter
blackbox_exporter.service - Blackbox Exporter
   Loaded: loaded (/etc/systemd/system/blackbox_exporter.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2023-05-09 15:20:40 GMT; 5s ago
  Process: 22483 ExecStart=/usr/local/bin/blackbox_exporter --config.file /etc/blackbox_exporter/blackbox.yml (code=exited, status=1/FAILURE)
 Main PID: 22483 (code=exited, status=1/FAILURE)

May 09 15:20:40 hostname systemd[1]: Started Blackbox Exporter.
May 09 15:20:40 hostname systemd[1]: blackbox_exporter.service: main process exited, code=exited, status=1/FAILURE
May 09 15:20:40 hostname systemd[1]: Unit blackbox_exporter.service entered failed state.
May 09 15:20:40 hostname systemd[1]: blackbox_exporter.service failed.

私は別のボックスでPrometheusを実行しています。これがブラックボックスエクスポートプログラムとPrometheusを別々のボックスで動作するかどうかはわかりませんが、試してみたいです。何らかの理由でPrometheusがローカルにないことが問題の原因である可能性があると考え、次の手順を使用してPrometheusをローカルにインストールしてみました。https://devconnected.com/how-to-setup-grafana-and-prometheus-on-linux/

残念ながら私も同じ問題があります。コマンドラインからPrometheusを起動できますが、sudo systemctl start prometheusを使用して起動することはできません。また、私が調査した他のスレッドでこれが問題であることがわかったので、この特定のシステムではSELinuxが無効になっていることに言及します。誰でも欲しいですか?ティア!

ベストアンサー1

上記のコマンドは有効です。

/usr/local/bin/blackbox_exporter --config.file=/etc/blackbox/blackbox.yml --web.listen-address=":9115"

サービス定義の内容:

ExecStart=/usr/local/bin/blackbox_exporter --config.file /etc/blackbox_exporter/blackbox.yml

慎重に見てください。構成ファイルのパスが同じではありません。ディレクトリは/etc/blackbox_exporter存在しますか?たぶんそうではないかもしれません。それはあなたの問題です。また、デフォルトポートではない場合は、ポート9115などのいくつかのオプションを追加することもできます。

/etc/systemd/system/blackbox_exporter.service ファイルを編集してサービス定義を調整し、systemctl daemon-reloadサービスを再実行して開始します。

おすすめ記事