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서비스를 다시 실행하고 시작해 보세요.

답변2

결국 설명된 대로 구성 파일 blackbox.service에 구성된 명령이 마음에 들지 않는 것이 발견되었습니다.

ExecStart=/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/blackbox.yml \
  --web.listen-address=127.0.0.1:9115

관련 정보