Member-only story
Prometheus AlertmanagerをTelegramでアラートで送信
6 min readAug 4, 2021
1. Telegrambotの作成
Follow the guilde in Telegram
Telegram docsのドキュメントのガイドに従ってください。
ドキュメント:https://core.telegram.org/bots#creating-a-new-bot
テレグラムトークンIDを受け取ります。これを保管しておいてください。後で使用します。
2. アラートを受け取るための新しいグループを作成し、ボットをグループに追加します。
Alter ボットがグループに参加すると、グループのチャットIDを受け取ることができます。
Chat id is ‘-4xxxxxxxx’
Create and build telegrambot docker image
telegrambotのdockerイメージの作成と構築
1. githubからTelegram botのソースコードをクローンします。
git clone github.com/inCaller/prometheus_bot
2. ソースコードへの移行
cd prometheus_bot/
3. Dockerfileの編集
FROM golang:1.14.4-alpine3.12 as builderRUN apk add --no-cache git ca-certificates make tzdataCOPY . /appRUN cd /app && \go get -d -v && \CGO_ENABLED=0 GOOS=linux go build -v -a -installsuffix cgo -o prometheus_botFROM alpine:3.12COPY --from=builder /app/prometheus_bot /RUN apk add --no-cache ca-certificates tzdata tiniRUN mkdir /etc/telegrambot/USER nobody