发布时间: 2024-11-18 文章作者: myluzh 分类名称: Kubernetes 朗读文章
# 创建一个带有邮件告警信息的配置 root@iZbp1bddlmdujngbc11omnZ:~/prom# vi alertmanager.yaml global: resolve_timeout: 5m smtp_smarthost: 'smtp.exmail.qq.com:465' smtp_hello: 'itho.cn' smtp_from: 'support@itho.cn' smtp_auth_username: 'support@itho.cn' smtp_auth_password: 'xxxxxxxxx' smtp_require_tls: true inhibit_rules: - equal: - namespace - alertname source_match: severity: critical target_match_re: severity: warning|info - equal: - namespace - alertname source_match: severity: warning target_match_re: severity: info receivers: - name: email_myluzh email_configs: - to: 'myluzh@qq.com' send_resolved: true - name: null_receiver route: group_by: - namespace group_interval: 5m group_wait: 30s receiver: email_myluzh repeat_interval: 12h routes: - match: alertname: Watchdog receiver: null_receiver - match: severity: critical receiver: null_receiver # 从 alertmanager.yaml 文件生成一个 Kubernetes Secret 资源的 YAML 文件,并将其内容保存到 alertmanager-main-generated.yaml 文件中 root@iZbp1bddlmdujngbc11omnZ:~/prom# kubectl create secret generic alertmanager-main-generated --from-file=alertmanager.yaml --dry-run=client -o yaml > alertmanager-main-generated.yaml # 删除原来有alertmanager-main-generated配置 root@iZbp1bddlmdujngbc11omnZ:~/prom# kubectl delete secrets alertmanager-main-generated -n monitoring secret "alertmanager-main-generated" deleted # 应用新的alertmanager-main-generated配置 root@iZbp1bddlmdujngbc11omnZ:~/prom# kubectl apply -f alertmanager-main-generated.yaml -n monitoring secret/alertmanager-main-generated created
route: group_by: - namespace group_interval: 5m group_wait: 30s receiver: null_receiver # 默认接收器,不发送告警 repeat_interval: 12h routes: - match: namespace: dev-test # 仅匹配 namespace="dev-test" receiver: email_myluzh receivers: - name: email_myluzh email_configs: - send_resolved: true to: myluzh@qq.com - name: null_receiver # 空接收器,不发送告警
标签: 邮件告警 Prometheus Alertmanager
发表评论