AlertManager는 Prometheus Server와 같은 클라이언트 응용 프로그램에서 보낸 경고를 처리합니다. WebHook 수신기 덕분에 이메일, PagerDuty, OpsGenie 또는 기타 여러 메커니즘과 같은 올바른 수신기 통합으로 중복 제거, 그룹화 및 라우팅을 처리해야합니다. 또한 경고의 침묵과 억제를 처리합니다.
AlertManager를 설치하는 다양한 방법이 있습니다.
릴리스 버전을위한 사전 컴파일 된 바이너리는 Prometheus.io의 다운로드 섹션에서 제공됩니다. 최신 프로덕션 릴리스 바이너리 사용은 AlertManager를 설치하는 권장 방법입니다.
Docker Images는 Quay.io 또는 Docker Hub에서 사용할 수 있습니다.
당신은 그것을 시도하기 위해 AlertManager 컨테이너를 발사 할 수 있습니다.
$ docker run --name alertmanager -d -p 127.0.0.1:9093:9093 quay.io/prometheus/alertmanager
AlertManager는 이제 http : // localhost : 9093/에서 도달 할 수 있습니다.
당신은 그것을 go get 수 있습니다 :
$ GO15VENDOREXPERIMENT=1 go get github.com/prometheus/alertmanager/cmd/...
# cd $GOPATH/src/github.com/prometheus/alertmanager
$ alertmanager --config.file=<your_file>
또는 저장소를 복제하고 수동으로 빌드하십시오.
$ mkdir -p $GOPATH/src/github.com/prometheus
$ cd $GOPATH/src/github.com/prometheus
$ git clone https://github.com/prometheus/alertmanager.git
$ cd alertmanager
$ make build
$ ./alertmanager --config.file=<your_file>
또한 빌드 함수에 이름을 전달 하여이 레포지에있는 바이너리 중 하나만 구축 할 수 있습니다.
$ make build BINARIES=amtool
이것은 새로운 YAML 구성 형식의 가장 관련성있는 측면을 다루어야하는 예제 구성입니다. 구성의 전체 문서는 여기에서 찾을 수 있습니다.
global :
# The smarthost and SMTP sender used for mail notifications.
smtp_smarthost : ' localhost:25 '
smtp_from : ' [email protected] '
# The root route on which each incoming alert enters.
route :
# The root route must not have any matchers as it is the entry point for
# all alerts. It needs to have a receiver configured so alerts that do not
# match any of the sub-routes are sent to someone.
receiver : ' team-X-mails '
# The labels by which incoming alerts are grouped together. For example,
# multiple alerts coming in for cluster=A and alertname=LatencyHigh would
# be batched into a single group.
#
# To aggregate by all possible labels use '...' as the sole label name.
# This effectively disables aggregation entirely, passing through all
# alerts as-is. This is unlikely to be what you want, unless you have
# a very low alert volume or your upstream notification system performs
# its own grouping. Example: group_by: [...]
group_by : ['alertname', 'cluster']
# When a new group of alerts is created by an incoming alert, wait at
# least 'group_wait' to send the initial notification.
# This way ensures that you get multiple alerts for the same group that start
# firing shortly after another are batched together on the first
# notification.
group_wait : 30s
# When the first notification was sent, wait 'group_interval' to send a batch
# of new alerts that started firing for that group.
group_interval : 5m
# If an alert has successfully been sent, wait 'repeat_interval' to
# resend them.
repeat_interval : 3h
# All the above attributes are inherited by all child routes and can
# overwritten on each.
# The child route trees.
routes :
# This route performs a regular expression match on alert labels to
# catch alerts that are related to a list of services.
- matchers :
- service=~"^(foo1|foo2|baz)$"
receiver : team-X-mails
# The service has a sub-route for critical alerts, any alerts
# that do not match, i.e. severity != critical, fall-back to the
# parent node and are sent to 'team-X-mails'
routes :
- matchers :
- severity="critical"
receiver : team-X-pager
- matchers :
- service="files"
receiver : team-Y-mails
routes :
- matchers :
- severity="critical"
receiver : team-Y-pager
# This route handles all alerts coming from a database service. If there's
# no team to handle it, it defaults to the DB team.
- matchers :
- service="database"
receiver : team-DB-pager
# Also group alerts by affected database.
group_by : [alertname, cluster, database]
routes :
- matchers :
- owner="team-X"
receiver : team-X-pager
- matchers :
- owner="team-Y"
receiver : team-Y-pager
# Inhibition rules allow to mute a set of alerts given that another alert is
# firing.
# We use this to mute any warning-level notifications if the same alert is
# already critical.
inhibit_rules :
- source_matchers :
- severity="critical"
target_matchers :
- severity="warning"
# Apply inhibition if the alertname is the same.
# CAUTION:
# If all label names listed in `equal` are missing
# from both the source and target alerts,
# the inhibition rule will apply!
equal : ['alertname']
receivers :
- name : ' team-X-mails '
email_configs :
- to : ' [email protected], [email protected] '
- name : ' team-X-pager '
email_configs :
- to : ' [email protected] '
pagerduty_configs :
- routing_key : <team-X-key>
- name : ' team-Y-mails '
email_configs :
- to : ' [email protected] '
- name : ' team-Y-pager '
pagerduty_configs :
- routing_key : <team-Y-key>
- name : ' team-DB-pager '
pagerduty_configs :
- routing_key : <team-DB-key> 현재 AlertManager API는 버전 2입니다.이 API는 OpenAPI 프로젝트를 통해 완전히 생성되며 HTTP 핸들러 자체를 제외하고 Swagger가됩니다. API 사양은 API/V2/OpenApi.yaml에서 찾을 수 있습니다. HTML 렌더링 버전에 액세스 할 수 있습니다. 모든 주요 언어에 대한 OpenAPI 생성기를 통해 클라이언트를 쉽게 생성 할 수 있습니다.
기본 구성을 사용하면 /api/v1 또는 /api/v2 접두사에서 엔드 포인트가 액세스됩니다. v2 /status 종말점은 /api/v2/status 입니다. --web.route-prefix 설정된 경우 API 경로는 이와 접두사로 표시되므로 --web.route-prefix=/alertmanager/ /alertmanager/api/v2/status 와 관련이 있습니다.
API V2는 여전히 큰 발전을 받고있어 변경 될 수 있습니다.
amtool AlertManager API와 상호 작용하기위한 CLI 도구입니다. AlertManager의 모든 릴리스와 함께 번들로 제공됩니다.
또는 다음과 같이 설치할 수 있습니다.
$ go install github.com/prometheus/alertmanager/cmd/amtool@latest
현재 발사 경고를 모두보기 :
$ amtool alert
Alertname Starts At Summary
Test_Alert 2017-08-02 18:30:18 UTC This is a testing alert!
Test_Alert 2017-08-02 18:30:18 UTC This is a testing alert!
Check_Foo_Fails 2017-08-02 18:30:18 UTC This is a testing alert!
Check_Foo_Fails 2017-08-02 18:30:18 UTC This is a testing alert!
확장 된 출력으로 현재 발사 된 모든 경고를보십시오.
$ amtool -o extended alert
Labels Annotations Starts At Ends At Generator URL
alertname="Test_Alert" instance="node0" link="https://example.com" summary="This is a testing alert!" 2017-08-02 18:31:24 UTC 0001-01-01 00:00:00 UTC http://my.testing.script.local
alertname="Test_Alert" instance="node1" link="https://example.com" summary="This is a testing alert!" 2017-08-02 18:31:24 UTC 0001-01-01 00:00:00 UTC http://my.testing.script.local
alertname="Check_Foo_Fails" instance="node0" link="https://example.com" summary="This is a testing alert!" 2017-08-02 18:31:24 UTC 0001-01-01 00:00:00 UTC http://my.testing.script.local
alertname="Check_Foo_Fails" instance="node1" link="https://example.com" summary="This is a testing alert!" 2017-08-02 18:31:24 UTC 0001-01-01 00:00:00 UTC http://my.testing.script.local
알림을 보는 것 외에도 AlertManager에서 제공하는 Rich Query 구문을 사용할 수 있습니다.
$ amtool -o extended alert query alertname="Test_Alert"
Labels Annotations Starts At Ends At Generator URL
alertname="Test_Alert" instance="node0" link="https://example.com" summary="This is a testing alert!" 2017-08-02 18:31:24 UTC 0001-01-01 00:00:00 UTC http://my.testing.script.local
alertname="Test_Alert" instance="node1" link="https://example.com" summary="This is a testing alert!" 2017-08-02 18:31:24 UTC 0001-01-01 00:00:00 UTC http://my.testing.script.local
$ amtool -o extended alert query instance=~".+1"
Labels Annotations Starts At Ends At Generator URL
alertname="Test_Alert" instance="node1" link="https://example.com" summary="This is a testing alert!" 2017-08-02 18:31:24 UTC 0001-01-01 00:00:00 UTC http://my.testing.script.local
alertname="Check_Foo_Fails" instance="node1" link="https://example.com" summary="This is a testing alert!" 2017-08-02 18:31:24 UTC 0001-01-01 00:00:00 UTC http://my.testing.script.local
$ amtool -o extended alert query alertname=~"Test.*" instance=~".+1"
Labels Annotations Starts At Ends At Generator URL
alertname="Test_Alert" instance="node1" link="https://example.com" summary="This is a testing alert!" 2017-08-02 18:31:24 UTC 0001-01-01 00:00:00 UTC http://my.testing.script.local
침묵 경고 :
$ amtool silence add alertname=Test_Alert
b3ede22e-ca14-4aa0-932c-ca2f3445f926
$ amtool silence add alertname="Test_Alert" instance=~".+0"
e48cb58a-0b17-49ba-b734-3585139b1d25
침묵보기 :
$ amtool silence query
ID Matchers Ends At Created By Comment
b3ede22e-ca14-4aa0-932c-ca2f3445f926 alertname=Test_Alert 2017-08-02 19:54:50 UTC kellel
$ amtool silence query instance=~".+0"
ID Matchers Ends At Created By Comment
e48cb58a-0b17-49ba-b734-3585139b1d25 alertname=Test_Alert instance=~.+0 2017-08-02 22:41:39 UTC kellel
침묵을 만료하십시오.
$ amtool silence expire b3ede22e-ca14-4aa0-932c-ca2f3445f926
쿼리와 일치하는 모든 침묵을 만료하십시오.
$ amtool silence query instance=~".+0"
ID Matchers Ends At Created By Comment
e48cb58a-0b17-49ba-b734-3585139b1d25 alertname=Test_Alert instance=~.+0 2017-08-02 22:41:39 UTC kellel
$ amtool silence expire $(amtool silence query -q instance=~".+0")
$ amtool silence query instance=~".+0"
모든 침묵을 만료하십시오.
$ amtool silence expire $(amtool silence query -q)
템플릿의 작동 방식을 사용해보십시오. 구성 파일에 이것을 가지고 있다고 가정 해 봅시다.
templates:
- '/foo/bar/*.tmpl'
그런 다음이 명령을 사용하여 예제로 템플릿의 모습을 테스트 할 수 있습니다.
amtool template render --template.glob='/foo/bar/*.tmpl' --template.text='{{ template "slack.default.markdown.v1" . }}'
amtool 사용하면 구성 파일이 편의를 위해 일부 옵션을 지정할 수 있습니다. 기본 구성 파일 경로는 $HOME/.config/amtool/config.yml 또는 /etc/amtool/config.yml 입니다
구성 파일 예제는 다음과 같습니다.
# Define the path that `amtool` can find your `alertmanager` instance
alertmanager.url: "http://localhost:9093"
# Override the default author. (unset defaults to your username)
author: [email protected]
# Force amtool to give you an error if you don't include a comment on a silence
comment_required: true
# Set a default output format. (unset defaults to simple)
output: extended
# Set a default receiver
receiver: team-X-pager
amtool 사용하면 구성 경로를 텍스트 트리보기 형태로 시각화 할 수 있습니다. 또한 경고의 라벨 세트를 전달하여 라우팅을 테스트하는 데 사용될 수 있으며 모든 수신기를 인쇄합니다 , (사용하는 경우 --verify.receivers Amtool은 불일치에서 오류 코드 1을 반환합니다)
사용의 예 :
# View routing tree of remote Alertmanager
$ amtool config routes --alertmanager.url=http://localhost:9090
# Test if alert matches expected receiver
$ amtool config routes test --config.file=doc/examples/simple.yml --tree --verify.receivers=team-X-pager service=database owner=team-X
Alertmanager의 고 가용성은 많은 회사에서 생산 중이며 기본적으로 활성화됩니다.
중요 : 클러스터가 작동하기 위해서는 AlertManager 0.15 이상에서 UDP와 TCP가 모두 필요합니다.
- 방화벽을 사용하는 경우 두 프로토콜의 클러스터링 포트를 화이트리스트에 올리십시오.
- 컨테이너에서 실행중인 경우 두 프로토콜에 클러스터링 포트를 노출하십시오.
ALERTMANAGER의 고용 가능한 클러스터를 만들려면 서로 통신하려면 인스턴스를 구성해야합니다. --cluster.* 플래그를 사용하여 구성됩니다.
--cluster.listen-address 문자열 : 클러스터 청취 주소 (기본 "0.0.0.0:9094"; 빈 문자열 HA 모드 비활성화)--cluster.advertise-address 문자열 : 클러스터 광고 주소--cluster.peer value : 초기 피어 (각 추가 피어에 대해 플래그를 반복)--cluster.peer-timeout 값 : 피어 타임 아웃 기간 (기본 "15s")--cluster.gossip-interval 값 : 클러스터 메시지 전파 속도 (기본 "200ms")--cluster.pushpull-interval 값 : 낮은 값은 대역폭을 희생시켜 수렴 속도를 증가시킵니다 (기본 "1m0s")--cluster.settle-timeout 값 : 알림을 평가하기 전에 클러스터 연결이 해결 될 때까지 기다리는 최대 시간입니다.--cluster.tcp-timeout 값 : TCP 연결의 시간 초과 값, 읽기 및 쓰기 (기본 "10S")--cluster.probe-timeout 값 : Node를 표시하기 전에 ACK를 기다리는 시간 건강에 해로운 상태 (기본 "500ms")--cluster.probe-interval 값 : 랜덤 노드 프로브 간격 (기본 "1s")--cluster.reconnect-interval 값 : 잃어버린 피어와 다시 연결하려는 시도 간의 간격 (기본 "10s")--cluster.reconnect-timeout 값 : 잃어버린 피어와 다시 연결하려는 시간 (기본값 : "6H0M0S")--cluster.label 값 : 레이블은 각 패킷과 스트림에 포함 할 선택적 문자열입니다. 클러스터를 독특하게 식별하고 가십 메시지를 보낼 때 교차 통신 문제를 방지합니다 (기본값 : ""). cluster.listen-address 에서 선택한 포트는 다른 피어의 cluster.peer 플래그에 지정 해야하는 포트입니다.
인스턴스에 기본 경로가있는 RFC 6890의 일부인 IP 주소가없는 경우 클러스터. cluster.advertise-address 플래그가 필요합니다.
로컬 컴퓨터에서 3 명의 피어 클러스터를 시작하려면이 저장소 내에서 goreman 과 Procfile을 사용하십시오.
goreman start
Prometheus 1.4 이상, 인스턴스를 여러 경보기에 가리키면 prometheus.yml 구성 파일에서 다음과 같이 구성하십시오.
alerting :
alertmanagers :
- static_configs :
- targets :
- alertmanager1:9093
- alertmanager2:9093
- alertmanager3:9093중요 : Prometheus와 Alertmanagers 사이의 균형 트래픽을로드하지 말고 Prometheus를 모든 경보기 목록으로 지적하십시오. AlertManager 구현은 모든 경보가 모든 경보기에게 전송되어 고 가용성을 보장 할 것으로 기대합니다.
고 가용성 모드에서 ALERTMANAGER를 실행하는 것이 바람직하지 않은 경우 --cluster.listen-address= alertmanager가 들어오는 피어 요청을 듣지 못하게합니다.
Prometheus 기고 페이지를 확인하십시오.
사용자 인터페이스에 기여하려면 UI/App/Contributing.md를 참조하십시오.
Apache License 2.0, 라이센스를 참조하십시오.