donaricano-btn

프로메테우스 알림매니저 실행 - Prometheuse alertmanager via slack


1. 정의

- 프로메테우스는 alert 시스템을 제공한다. 

- slack, hipchat 등 을 통하여 alert을 받을 수 있다.

- 만약 node_exporter 가 설치된 서버에 node_exporter가 죽으면 instance가 죽었다는 alert을 받는다.


2. AlertManager 구성

- https://prometheus.io/docs/alerting/overview/

- 두 파트로 나뉜다, Alert rules, Alert manager

- Alert rules가 Alert manager에게 alert 메시지를 전송하면 Alert manager는 슬랙, 이메일, 힙챗 등을 통하여 사용자게에 보여준다


3. AlertManger설치 및 설정

1) AlertManager 설치

- https://prometheus.io/download/ OS에 맞는 AlertManager를 다운받는다.

- simple.yml


- 해당 설정 파일을 통하여 AlertManager를 설정할 수 있다.

- 위 설정은 slack 을 이용한 alert를 받기 위한 설정이다. 

- global : 이 영역에 slack, hipchat 같은 api를 작성한다.

- route : 최상위 노드로서 group의 이름, 시간 등을 설정한다. 

- receivers : slack 채널을 설정

https://prometheus.io/docs/alerting/configuration/

- ./alertmanager.exe --conifg.file=simple.yml 실행

- localhost:9093에 접속하면 AlertManger 화면에 접속할 수 있다. 


4. Alertrules 설정 및 Slack 연결 

- AlertManager를 설치 했다면 AlertRule를 설정한다. Rule 설정은 프로메테우스 서버에서 설정한다. 

1) Prometheus.yml

 

- rule_files : Alertrules 파일을 따로 만들어서 이곳에서 loading 되도록 한다.

- alerting :  AlertManger와 연결하는 부분

- 과거 버전(x): ./prometheus.exe --config.file=prometheus.yml --alertmanager.url=http://localhost:9093

- 최신 버전(o) : prometheus.yml 파일에 직접 셋팅한다.

2) alert.rules.yml

- 과거버전

 

- 최신 버전

- ALERT RULE 포맷이 아닌 YAML 포맷을 따른다. 

 

- 변환 방법

- rules 파일을 먼저 만들고 promtool 을 이용하여 update 하면 자동으로 변환된다.

- ./promtool.exe update rules alert.rules


5. 확인

- ./alertmanager.exe --config.file=simple.yml 을 띄운다

- ./prometheus.exe --config.file=prometheus.yml 실행

- 이후에 node_exporter가 설치된 서버에 접속하여 node_exporter 를 죽인다

- localhost:9090/alerts, localhost:9093 에 접속하여 확인






블로그 이미지

리딩리드

,