
저는 Prometheus의 경고를 관리하기 위해 Prometheus의 Alertmanager를 설정했습니다. Prometheus에서 Alertmanager로 경고가 들어오지만 여기서 이야기는 끝납니다. 경고는 Alertmanager에서 내 이메일 엔드포인트로 전송되지 않습니다.
Alertmanager 내에서 경고가 종료되는 위치를 정확히 파악하기 위해 로그 수준을 정보에서 디버그로 전환하고 싶지만 방법을 알 수 없습니다. 로그를 찾는 것조차 지금 당장은 어려운 질문처럼 보입니다. 로그에 포함되어 있지도 않고 /var/log
포함 journalctl -u alertmanager
된 내용도 너무 적어서 어딘가에 다른 로그가 있을 수도 있습니다.
매뉴얼 페이지Alertmanager 구성디버그 수준은 언급하지 않습니다. 로그에 대한 언급이 있는 소스 코드를 살펴본 결과 설정 이름이 로 지정되어야 한다는 것을 알았습니다 log.level
. 구성 YAML에 다음 코드 조각을 추가해도 도움이 되지 않았습니다.
log:
level: debug
Alertmanager가 구성 파일을 구문 분석하지 못해 시작하지 못했습니다.
답변1
대답은 구성 파일을 통해 디버깅하도록 Prometheus의 Alertmanagers 로그 수준을 설정할 수 없으며 명령줄 인수를 통해서만 가능하다는 것입니다. 이유를 묻지 마세요. 분명 이유가 있을 거라 확신합니다.
Puppet을 통해 Alertmanager의 Systemd 장치 파일에 인수를 추가하여 결과는 다음과 같습니다.
[Unit]
Description=Prometheus alertmanager
Wants=basic.target
After=basic.target network.target
[Service]
User=alertmanager
Group=alertmanager
EnvironmentFile=/etc/sysconfig/alertmanager
ExecStart=/usr/local/bin/alertmanager \
--config.file=/etc/alertmanager/alertmanager.yaml \
--storage.path=/var/lib/alertmanager \
--log.level=debug
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
[Install]
WantedBy=multi-user.target
쉘에서 Alertmanager를 시작하는 경우 --log.level=debug
호출에 플래그를 추가하기만 하면 됩니다.
디버그 메시지는 journalctl -u alertmanager
Systemd init 시스템이 있는 Linux 배포판을 통해 볼 수 있습니다.
답변2
Ubuntu 시스템(prometheus-alertmanager가 apt 및 공식 저장소를 통해 설치된 경우)
열려 있는
/etc/default/prometheus-alertmanager
그리고 추가하세요
ARGS="--log.level=debug"
파일로(ARGS="" 교체)
그런 다음 systemd를 통해 prometheus-alertmanager를 다시 시작하십시오.
sudo systemctl restart prometheus-alertmanager.service
Journalctl을 통해 로그를 표시합니다.
journalctl -u prometheus-alertmanager.service --since today
답변3
내에서는 docker-compose.yml
다음을 수행했습니다.command: --log.level=debug
자세히보다:
alertmanager:
restart: unless-stopped
image: prom/alertmanager:latest
command:
- '--config.file=/etc/alertmanager/alertmanager.yml'
- '--storage.path=/alertmanager'
- '--log.level=debug'
volumes:
- ./alertmanager.yml:/etc/alertmanager/alertmanager.yml
expose:
- 9093/tcp
networks:
monitoring-net: