首页 > 其他分享 >PrometheusAlert微信报警模板示例

PrometheusAlert微信报警模板示例

时间:2023-04-05 21:56:40浏览次数:47  
标签:01 end kubernetes 示例 微信 labels PrometheusAlert instance Pod

配置入口如下:

 代码配置:

{{ $var := .externalURL}}
{{ range $k,$v:=.alerts }}
    {{if eq $v.status "resolved"}}[PROMETHEUS-恢复信息]({{$v.generatorURL}})
        > **[{{$v.labels.alertname}}]({{$var}})**
        > <font color="info">开始时间:</font> {{ TimeFormat $v.startsAt "2006-01-02 15:04:05" }}
        > <font color="info">结束时间:</font> {{ TimeFormat $v.endsAt "2006-01-02 15:04:05" }}
        > <font color="info">故障主机:</font> {{- if $v.labels.instance }} {{ $v.labels.instance }} {{- end }}
        > <font color="info">**{{$v.annotations.description}} {{- if $v.labels.biz_no }} {{ $v.labels.biz_no }} {{- end }}**</font>
    {{else}}[PROMETHEUS-告警信息]({{$v.generatorURL}})
        > **[{{$v.labels.alertname}}]({{$var}})**
        > <font color="warning">开始时间:</font> {{ TimeFormat $v.startsAt "2006-01-02 15:04:05" }}
        > <font color="warning">结束时间:</font> {{ TimeFormat $v.endsAt "2006-01-02 15:04:05" }}
        > <font color="warning">故障主机:</font> {{- if $v.labels.instance }} {{ $v.labels.instance }} {{- end }}
        > <font color="warning">**{{$v.annotations.description}} {{- if $v.labels.biz_no }} {{ $v.labels.biz_no }} {{- end }}**</font>
    {{end}}
{{ end }}

 校验示例:

{
    "receiver": "email_and_weixin",
    "status": "firing",
    "alerts": [{
        "status": "firing",
        "labels": {
            "alertname": "K8S Pod节点监控告警",
            "condition": "true",
            "env": "test",
            "instance": "10.42.172.136:8080",
            "job": "kubernetes-service-endpoints",
            "kubernetes_name": "kube-state-metrics",
            "kubernetes_namespace": "kube-system",
            "label": "3",
            "namespace": "default",
            "pod": "xinao-planet-product-6b5746c67-n2kcl",
            "severity": "critical",
            "uid": "f284b05a-bd06-450a-a3e4-5fa7b514cbb7"
        },
        "annotations": {
            "description": "Pod has been in a non-ready state for longer than 2 seconds.",
            "summary": "Kubernetes Pod not healthy (instance 10.42.172.136:8080)"
        },
        "startsAt": "2023-03-27T02:47:59.695Z",
        "endsAt": "0001-01-01T00:00:00Z",
        "generatorURL": "http://prometheus-c56654849-6447l:9090/graph?g0.expr=kube_pod_status_ready%7Bcondition%3D%22true%22%2Cpod%3D~%22.%2Aplanet.%2A%22%7D+%3D%3D+0&g0.tab=1",
        "fingerprint": "5c721c56bb727fd4"
    }],
    "groupLabels": {},
    "commonLabels": {
        "alertname": "K8S Pod节点监控告警",
        "condition": "true",
        "env": "test",
        "instance": "10.42.172.136:8080",
        "job": "kubernetes-service-endpoints",
        "kubernetes_name": "kube-state-metrics",
        "kubernetes_namespace": "kube-system",
        "label": "3",
        "namespace": "default",
        "pod": "xinao-planet-product-6b5746c67-n2kcl",
        "severity": "critical",
        "uid": "f284b05a-bd06-450a-a3e4-5fa7b514cbb7"
    },
    "commonAnnotations": {
        "description": "Pod has been in a non-ready state for longer than 2 seconds.",
        "summary": "Kubernetes Pod not healthy (instance 10.42.172.136:8080)"
    },
    "externalURL": "http://za-monitor-test-0001:9093",
    "version": "4",
    "groupKey": "{}/{severity=\"critical\"}:{}",
    "truncatedAlerts": 0
}

可以在PrometheusAlert的MarkDown入口进行校验。

标签:01,end,kubernetes,示例,微信,labels,PrometheusAlert,instance,Pod
From: https://www.cnblogs.com/huajun0525/p/17277223.html

相关文章

  • 微信小程序Server端环境配置
    源码地址:https://github.com/Tinywan/PHP_Experience主要内容:1.SSL免费证书申请步骤2.NginxHTTPS配置3.TLS1.2升级过程 微信小程序要求使用 https 发送请求,那么Web服务器就要配置成支持 https,需要先申请SSL证书小程序也要求 TLS(传输层安全协议)的版本至少为 1.2,在配置......
  • 微信接口开发之高级篇系列【网页授权接口】
    【1】带微信帐号的手机 【2】打开浏览器,这里以IE为例。     输入:http://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login【3】用手机登录你的微信,使用微信中的“扫一扫”功能,扫描上面网页中的二维码。在手机上会出现以下界面:......
  • 微信小程序入门教程(一)API接口数据记录
    今天测试用小程序调用API接口,发现有些数据打印都是对象,怎么全部打印详细点来小程序代码:httpsearch:function(name,offset,type,cb){wx.request({url:'https://www.tinywan.com/api/wechat/songsSearch',data:{name:name,offset:o......
  • 你真的需要一个微信公众号吗?
    阅读本文大概需要4分钟。      最近看到很多人后台问我各种开通个人公众号的问题,如怎么开通原创功能啊,怎么开通赞赏功能啊,可能读者中也有很大一部分人已经或者将要开通自己的微信公众号,这篇文章姑且我就分享下我个人运营公号的一些宝贵经验,给你们做些参考,相信看完你......
  • Jenkins持续集成,接口测试报告发送企业微信
    一、前置条件已经安装Jenkins(361.1)已经安装jdk(jdk17)Jdk和Jenkins版本相互兼容二、启动Jenkins(注意不要关闭dos窗口)切换到Jenkins目录,输入命令:java-jarjenkins.war        2.dos窗口出现“Jenkinsisfullyupandrunning”表示启动成功   ......
  • 知乎微信接口
    微信精选段子http://v.juhe.cn/weixin/query?key=d046cd1f569ed13d951f0258902ef9b2&ps=10知乎最新日报列表http://news-at.zhihu.com/api/4/news/latest知乎详情http://news-at.zhihu.com/api/4//news/{KaTeXparseerror:Expected'EOF',got'}'atposition3:......
  • 微信支付——微信退款+提现
    未封装的退款<?php//+----------------------------------------------------------------------//|Tplay[WEONLYDOWHATISNECESSARY]//+----------------------------------------------------------------------//|Copyright(c)2017http://tplay.pengyiche......
  • 微信证书
    windows版本:https://wx.gtimg.com/mch/files/WXCertUtil.exemac版本:https://wx.gtimg.com/mch/files/WXCertUtil.dmghttps://kf.qq.com/faq/161222NneAJf161222U7fARv.html......
  • 【fastweixin框架教程7】微信企业号自定义菜单接口开发
     下面这个类我对fastweixin框架的简单封装调用,大家可以参考,如果需要QYAPIConfigExt和MainServernSupport,请参考本教程以前几篇文章  应用可以在会话界面底部设置自定义菜单,菜单项可按需设定,并可为其设置响应动作。用户可以通过点击菜单项,收到你设定的消息。企业号支持自定义......
  • 01_微信公众号_话题_提取链接_一行一个
    nodejscheerio提取超链接import{log}from"console";import{readFileSync,readdirSync,lstatSync,createWriteStream,mkdirSync,statSync,}from"fs";import{basename,join,resolve}from"path";import{load......