O que é isso???
CLI que faz interação com alertmanager, facilitando a gerência dos alertas remotamente gerados pelo prometheus com base nas regras existentes no prometheus.
PREPARANDO O AMBIENTE:
DOWNLOAD:
go get github.com/prometheus/alertmanager/cmd/amtool
BUILD:
cd ~/go/src/github.com/prometheus/alertmanager/cmd/amtool
go build
CONFIGURANDO:
mv amtool /usr/local/bin
cat <<EOT>> ~/.config/amtool
# Define the path that amtool can find your `alertmanager` instance at
alertmanager.url: “http://localhost:9092”
# Override the default author. (unset defaults to your username)
author: Wellington Bastos
# 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: simple #extended
# Set a default receiver
receiver: default-receiver
EOT
UTILIZANDO COM KUBERNTES:
Fazer o port-forward para o seu alertmanager:
kubectl port-forward svc/prometheus-alertmanager 9092:9092
kubectl port-forward svc/prometheus-alertmanager 9092:{porta do seu alertmanager}
BUSCAR TODOS OS ALERTAS MODO SIMPLIFICADO:
watch -n1 ‘amtool alert’
BUSCAR TODOS OS ALERTAS MODO EXTENDIDO:
watch -n1 ‘amtool -o extended alert’
FAZENDO CONSULTAS NO ALERTMANAGER:
PELO NOME DO ALERTA:
amtool -o extended alert query alertname=”HighLoad15″
PELO TERMO MYSQL:
amtool -o extended alert query instance=~”.MYSQL”
PELO NOME DO ALERTA E INSTÂNCIA:
amtool -o extended alert query alertname=~”High.*” instance=~”.+MYSQL1″
MOSTRAR ALERTAS SILENCIADOS:
amtool silence query
BUSCA ALERTAS SILENCIADOS NO HOST QUE TIVER MYSQL NO NOME:
amtool silence query instance=~”.+MYSQL”
COLOCANDO UM ALERTA EM SILÊNCIO:
amtool silence add alertname=HighLoad15 -comment=teste
COLOCANDO UM ALERTA EM SILÊNCIO COM TERMOS:
amtool silence add alertname=”HighLoad15″ instance=~”.+MYSQL”
EXPIRANDO UM ALERTA EM SILÊNCIO:
amtool silence expire ID-DO-ALERTA-EM-SILENCIO
EXPIRANDO TODOS ALERTAS EM SILÊNCIO:
amtool silence expire $(amtool silence query -q)
Deixe um comentário