Linux 一键部署alertmanager

Posted CIAS

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux 一键部署alertmanager相关的知识,希望对你有一定的参考价值。

 

前言

Alertmanager处理客户端应用程序(例如 Prometheus 服务器)发送的警报。它负责删除重复数据、分组并将它们路由到正确的接收器集成,例如电子邮件、PagerDuty 或 OpsGenie。它还负责警报的静音和抑制。

创建一键安装alertmanager脚本

  • 默认此脚本实现邮件提醒
  • 默认端口 9093
  • 23-46行更改邮件提醒服务器相关账号密码信息
vim /alertmanager.sh
#!/bin/sh
# -*- coding: utf-8 -*-
# Date: 2022/12/02

echo "download alertmanager"
sleep 2
wget -N -P /root/ https://github.com/prometheus/alertmanager/releases/download/v0.24.0/alertmanager-0.24.0.linux-amd64.tar.gz

echo "decompression alertmanager"
sleep 2
tar -xvf /root/alertmanager-0.24.0.linux-amd64.tar.gz -C /usr/local/

echo "rechristen"
sleep 2
mv /usr/local/alertmanager-0.24.0.linux-amd64 /usr/local/alertmanager

echo "Clear alertmanager the Default Configuration"
sleep 2
echo > /usr/local/alertmanager/alertmanager.yml

echo "config alertmanager"
sleep 2
cat >>/usr/local/alertmanager/alertmanager.yml<<EOF
global:
  smtp_smarthost: 'smtp.qiye.163.com:25'
  smtp_from: 'YOU_email@cn.com'
  smtp_auth_username: 'YOU_email@cn.com'
  smtp_auth_password: 'YOU_email_password'
  smtp_require_tls: false

route:
  group_by: ['alertname']
  group_wait: 10s
  group_interval: 10s
  repeat_interval: 10m
  receiver: live-monitoring

receivers:
- name: 'live-monitoring'
  email_configs:
  - to: 'iYOU_email@cn.com'
    send_resolved: true
    headers:
      from: "Grafana Warnings Warnings"
      subject: "[operations] 报警邮件"
      to: "mYOU_email@cn.com"                               
EOF


echo "creation alertmanager.service"
sleep 2
cat >>/usr/lib/systemd/system/alertmanager.service<<EOF
[Unit]
Description=alertmanager
Documentation=https://github.com/prometheus/alertmanager/releases
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/alertmanager/alertmanager --config.file=/usr/local/alertmanager/alertmanager.yml
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

echo "start alertmanager.service"
sleep 2
systemctl daemon-reload && systemctl enable --now alertmanager

echo "rm alertmanager package"
sleep 2
rm -rf /root/alertmanager-0.24.0.linux-amd64.tar.gz

执行一键安装alertmanager 

sh /alertmanager.sh

alertmanager 部署完成,需要实现企业微信机器人提醒参考

  • http://YOU_IP:9093

 

以上是关于Linux 一键部署alertmanager的主要内容,如果未能解决你的问题,请参考以下文章

.NET Core 一键部署到Linux服务器以服务方式后台运行

Linux/Centos Mondo 一键部署镜像恢复,快速部署

Linux 一键部署alertmanager

Linux 一键部署alertmanager

Linux 一键部署alertmanager

基础--Linux环境一键部署