- 監視の設定やエクスポーターについては記述していません。
- Debian系はそのままaptコマンドで動きますが、RedHat系OSの場合はyumコマンドに置き換えてください。
prometheusのインストール
apt install prometheus prometheus-alertmanager
systemctl enable prometheus prometheus-alertmanager
alertmanager-discord
DLしてビルド
goが入っていない場合はインストール
Wiki
add-apt-repository ppa:longsleep/golang-backports
apt install golang-go
DLしてビルド
git clone https://github.com/benjojo/alertmanager-discord.git
cd alertmanager-discord
go build
cp alertmanager-discord /usr/local/bin/
Unitファイル作成
vim /lib/systemd/system/prometheus-alertmanager-discord.service
※-webhook.url
は自分のものに置き換えてください webhookの作成
※ 9094ポートが使用済みの場合は別のポートに書き換えてください
[Unit]
Description=alertmanager-discord
Documentation=https://github.com/benjojo/alertmanager-discord
After=network-online.target
[Service]
ExecStart=/usr/local/bin/alertmanager-discord -webhook.url=https://discord.com/api/webhooks/*********** -listen.address=127.0.0.1:9094
ExecStop=/bin/kill -TERM ${MAINPID}
ExecReload=/bin/kill -HUP ${MAINPID}
Restart=on-failure
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start prometheus-alertmanager-discord
systemctl enable prometheus-alertmanager-discord
alertmanagerの設定
vim /etc/prometheus/alertmanager.yml
route:
とreceivers:
の部分を書き足す
# /etc/prometheus/alertmanager.yml
---
global: {}
templates: []
route:
receiver: discord_webhook
routes: []
receivers:
- name: discord_webhook
webhook_configs:
- url: http://localhost:9094
inhibit_rules: []
これでDiscordにアラートが通知されるはずです。
後はお好みでexporterやアラートルールを設定してみてください!