feiyu563 / PrometheusAlert

Prometheus Alert是开源的运维告警中心消息转发系统,支持主流的监控系统Prometheus,Zabbix,日志系统Graylog和数据可视化系统Grafana发出的预警消息,支持钉钉,微信,华为云短信,腾讯云短信,腾讯云电话,阿里云短信,阿里云电话等
https://feiyu563.gitbook.io
MIT License
2.79k stars 672 forks source link

告警测试问题:报错beego application error #129

Closed superman-killig closed 3 years ago

superman-killig commented 3 years ago

image

superman-killig commented 3 years ago

2021/07/13 11:36:28.702 ^[[1;34m[I]^[[0m [prometheusalert.go:85] [1626147388701086422] [dingding] {"msgtype":"markdown","markdown":{"title":"PrometheusAlert告警消息","text":"\r\n\r\n## Prometheus告警信息\r\n#### TargetDown\r\n###### 告警级别:2\r\n###### 开始时间:2020-05-21T02:58:07.830216179Z\r\n###### 结束时间:0001-01-01T00:00:00Z\r\n###### 故障主机IP:example-1\r\n##### target was down! example dev /example-1 was down for more than 120s.\r\nPrometheus\r\n\r\n @13511xx"},"at":{"atMobiles":["135xxx"],"isAtAll":false}}

2021/07/13 11:36:28.793 ^[[1;31m[E]^[[0m [prometheusalert.go:85] [1626147388701086422] [dingding] Post "https://oapi.dingtalk.com/robot/send?access_token=c9b1b1401bbabf1db6e1eb9b30cc44cedf17656exxx": Bad Request 2021/07/13 11:36:28.793 ^[[1;35m[C]^[[0m [panic.go:965] the request url is /prometheusalert 2021/07/13 11:36:28.793 ^[[1;35m[C]^[[0m [panic.go:965] Handler crashed with error runtime error: invalid memory address or nil pointer dereference 2021/07/13 11:36:28.793 ^[[1;35m[C]^[[0m [panic.go:965] /usr/local/go/src/runtime/panic.go:965 2021/07/13 11:36:28.793 ^[[1;35m[C]^[[0m [panic.go:965] /usr/local/go/src/runtime/panic.go:212 2021/07/13 11:36:28.793 ^[[1;35m[C]^[[0m [panic.go:965] /usr/local/go/src/runtime/signal_unix.go:734 2021/07/13 11:36:28.793 ^[[1;35m[C]^[[0m [panic.go:965] /mnt/hgfs/code/golang/src/PrometheusAlert/controllers/dingding.go:84 2021/07/13 11:36:28.793 ^[[1;35m[C]^[[0m [panic.go:965] /mnt/hgfs/code/golang/src/PrometheusAlert/controllers/prometheusalert.go:85 2021/07/13 11:36:28.793 ^[[1;35m[C]^[[0m [panic.go:965] /mnt/hgfs/code/golang/src/PrometheusAlert/controllers/prometheusalert.go:59 2021/07/13 11:36:28.793 ^[[1;35m[C]^[[0m [panic.go:965] /usr/local/go/src/reflect/value.go:476 2021/07/13 11:36:28.793 ^[[1;35m[C]^[[0m [panic.go:965] /usr/local/go/src/reflect/value.go:337 2021/07/13 11:36:28.793 ^[[1;35m[C]^[[0m [panic.go:965] /mnt/hgfs/code/golang/src/PrometheusAlert/vendor/github.com/astaxie/beego/router.go:853 2021/07/13 11:36:28.793 ^[[1;35m[C]^[[0m [panic.go:965] /usr/local/go/src/net/http/server.go:2887 2021/07/13 11:36:28.793 ^[[1;35m[C]^[[0m [panic.go:965] /usr/local/go/src/net/http/server.go:1952 2021/07/13 11:36:28.793 ^[[1;35m[C]^[[0m [panic.go:965] /usr/local/go/src/runtime/asm_amd64.s:1371 2021/07/13 11:36:28.793 [server.go:3137] [HTTP] http: superfluous response.WriteHeader call from github.com/astaxie/beego/context.(*Response).WriteHeader (context.go:230)

feiyu563 commented 3 years ago

确认下配置文件是否正确,另外你使用的是哪种方式运行的PrometheusAlert

superman-killig commented 3 years ago

    centos系统本地运行,conf中已配置dingding告警地址。conf文件配置如下: image

------------------ 原始邮件 ------------------ 发件人: "feiyu563/PrometheusAlert" @.>; 发送时间: 2021年7月13日(星期二) 中午12:00 @.>; @.**@.>; 主题: Re: [feiyu563/PrometheusAlert] 告警测试问题:报错beego application error (#129)

确认下配置文件是否正确,另外你使用的是哪种方式运行的PrometheusAlert

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

feiyu563 commented 3 years ago

配置文件用不到的配一张不能删除,另外确认下你的配置文件名是不是app.conf

superman-killig commented 3 years ago

没有删除,配置文件名是app.conf。

---------------------↓全局配置-----------------------

appname = PrometheusAlert

登录用户名

login_user=prometheusalert

登录密码

login_password=prometheusalert

监听地址

httpaddr = 10.xxx

监听端口

httpport = 8000 runmode = dev

设置代理 proxy = http://123.123.123.123:8080

proxy = https://prometheusalert.自己域名.com/

开启JSON请求

copyrequestbody = true

告警消息标题

title=Prometheus

链接到告警平台地址

GraylogAlerturl=http://graylog.org

钉钉告警 告警logo图标地址

logourl=https://raw.githubusercontent.com/feiyu563/PrometheusAlert/master/doc/alert-center.png

钉钉告警 恢复logo图标地址

rlogourl=https://raw.githubusercontent.com/feiyu563/PrometheusAlert/master/doc/alert-center.png

短信告警级别(等于3就进行短信告警) 告警级别定义 0 信息,1 警告,2 一般严重,3 严重,4 灾难

messagelevel=3

电话告警级别(等于4就进行语音告警) 告警级别定义 0 信息,1 警告,2 一般严重,3 严重,4 灾难

phonecalllevel=4

默认拨打号码(页面测试短信和电话功能需要配置此项)

defaultphone=xxxxxxxx

故障恢复是否启用电话通知0为关闭,1为开启

phonecallresolved=0

自动告警抑制(自动告警抑制是默认同一个告警源的告警信息只发送告警级别最高的第一条告警信息,其他消息默认屏蔽,这么做的目的是为了减少相同告警来源的消息数量,防止告警炸弹,0为关闭,1为开启)

silent=0

是否前台输出file or console

logtype=file

日志文件路径

logpath=logs/prometheusalertcenter.log

转换Prometheus,graylog告警消息的时区为CST时区(如默认已经是CST时区,请勿开启)

prometheus_cst_time=0

数据库驱动,支持sqlite3,mysql,postgres如使用mysql或postgres,请开启db_host,db_port,db_user,db_password,db_name的注释

db_driver=sqlite3

db_driver=mysql db_host=10.xxx db_port=3306 db_user=xxx db_password=xxx db_name=prometheusalert

---------------------↓webhook-----------------------

是否开启钉钉告警通道,可同时开始多个通道0为关闭,1为开启

open-dingding=1

默认钉钉机器人地址

ddurl=https://oapi.dingtalk.com/robot/send?access_token=xxx

是否开启 @所有人(0为关闭,1为开启)

dd_isatall=1

是否开启微信告警通道,可同时开始多个通道0为关闭,1为开启

open-weixin=1

默认企业微信机器人地址

wxurl=https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxx

是否开启飞书告警通道,可同时开始多个通道0为关闭,1为开启

open-feishu=0

默认飞书机器人地址

fsurl=https://open.feishu.cn/open-apis/bot/hook/xxxxxxxxx

---------------------↓腾讯云接口-----------------------

是否开启腾讯云短信告警通道,可同时开始多个通道0为关闭,1为开启

open-txdx=0

腾讯云短信接口key

TXY_DX_appkey=xxxxx

腾讯云短信模版ID 腾讯云短信模版配置可参考 prometheus告警:{1}

TXY_DX_tpl_id=xxxxx

腾讯云短信sdk app id

TXY_DX_sdkappid=xxxxx

腾讯云短信签名 根据自己审核通过的签名来填写

TXY_DX_sign=腾讯云

是否开启腾讯云电话告警通道,可同时开始多个通道0为关闭,1为开启

open-txdh=0

腾讯云电话接口key

TXY_DH_phonecallappkey=xxxxx

腾讯云电话模版ID

TXY_DH_phonecalltpl_id=xxxxx

腾讯云电话sdk app id

TXY_DH_phonecallsdkappid=xxxxx

---------------------↓华为云接口-----------------------

是否开启华为云短信告警通道,可同时开始多个通道0为关闭,1为开启

open-hwdx=0

华为云短信接口key

HWY_DX_APP_Key=xxxxxxxxxxxxxxxxxxxxxx

华为云短信接口Secret

HWY_DX_APP_Secret=xxxxxxxxxxxxxxxxxxxxxx

华为云APP接入地址(端口接口地址)

HWY_DX_APP_Url=https://rtcsms.cn-north-1.myhuaweicloud.com:10743

华为云短信模板ID

HWY_DX_Templateid=xxxxxxxxxxxxxxxxxxxxxx

华为云签名名称,必须是已审核通过的,与模板类型一致的签名名称,按照自己的实际签名填写

HWY_DX_Signature=华为云

华为云签名通道号

HWY_DX_Sender=xxxxxxxxxx

---------------------↓阿里云接口-----------------------

是否开启阿里云短信告警通道,可同时开始多个通道0为关闭,1为开启

open-alydx=0

阿里云短信主账号AccessKey的ID

ALY_DX_AccessKeyId=xxxxxxxxxxxxxxxxxxxxxx

阿里云短信接口密钥

ALY_DX_AccessSecret=xxxxxxxxxxxxxxxxxxxxxx

阿里云短信签名名称

ALY_DX_SignName=阿里云

阿里云短信模板ID

ALY_DX_Template=xxxxxxxxxxxxxxxxxxxxxx

是否开启阿里云电话告警通道,可同时开始多个通道0为关闭,1为开启

open-alydh=0

阿里云电话主账号AccessKey的ID

ALY_DH_AccessKeyId=xxxxxxxxxxxxxxxxxxxxxx

阿里云电话接口密钥

ALY_DH_AccessSecret=xxxxxxxxxxxxxxxxxxxxxx

阿里云电话被叫显号,必须是已购买的号码

ALY_DX_CalledShowNumber=xxxxxxxxx

阿里云电话文本转语音(TTS)模板ID

ALY_DH_TtsCode=xxxxxxxx

---------------------↓容联云接口-----------------------

是否开启容联云电话告警通道,可同时开始多个通道0为关闭,1为开启

RLY_DH_open-rlydh=0

容联云基础接口地址

RLY_URL=https://app.cloopen.com:8883/2013-12-26/Accounts/

容联云后台SID

RLY_ACCOUNT_SID=xxxxxxxxxxx

容联云api-token

RLY_ACCOUNT_TOKEN=xxxxxxxxxx

容联云app_id

RLY_APP_ID=xxxxxxxxxxxxx

---------------------↓邮件配置-----------------------

是否开启邮件

open-email=0

邮件发件服务器地址

Email_host=smtp.qq.com

邮件发件服务器端口

Email_port=465

邮件帐号

@.***

邮件密码

Email_password=xxxxxx

邮件标题

Email_title=运维告警

默认发送邮箱

@.**@.

---------------------↓七陌云接口-----------------------

是否开启七陌短信告警通道,可同时开始多个通道0为关闭,1为开启

open-7moordx=0

七陌账户ID

7MOOR_ACCOUNT_ID=Nxxx

七陌账户APISecret

7MOOR_ACCOUNT_APISECRET=xxx

七陌账户短信模板编号

7MOOR_DX_TEMPLATENUM=n

注意:七陌短信变量这里只用一个var1,在代码里写死了。

-----------

是否开启七陌webcall语音通知告警通道,可同时开始多个通道0为关闭,1为开启

open-7moordh=0

请在七陌平台添加虚拟服务号、文本节点

七陌账户webcall的虚拟服务号

7MOOR_WEBCALL_SERVICENO=xxx

文本节点里被替换的变量,我配置的是text。如果被替换的变量不是text,请修改此配置

7MOOR_WEBCALL_VOICE_VAR=text

---------------------↓telegram接口-----------------------

是否开启telegram告警通道,可同时开始多个通道0为关闭,1为开启

open-tg=0

tg机器人token

TG_TOKEN=xxxxx

tg消息模式 个人消息或者频道消息 0为关闭(推送给个人),1为开启(推送给频道)

TG_MODE_CHAN=0

tg用户ID

TG_USERID=xxxxx

tg频道name

TG_CHANNAME=xxxxx

tg api地址, 可以配置为代理地址

TG_API_PROXY="https://api.telegram.org/bot%s/%s"

---------------------↓workwechat接口-----------------------

是否开启workwechat告警通道,可同时开始多个通道0为关闭,1为开启

open-workwechat=0

企业ID

WorkWechat_CropID=xxxxx

应用ID

WorkWechat_AgentID=xxxx

应用secret

WorkWechat_AgentSecret=xxxx

接受用户

WorkWechat_ToUser="zhangsan|lisi"

接受部门

WorkWechat_ToParty="ops|dev"

接受标签

WorkWechat_ToTag=""

消息类型, 暂时只支持markdown

WorkWechat_Msgtype = "markdown"

---------------------↓百度云接口-----------------------

是否开启百度云短信告警通道,可同时开始多个通道0为关闭,1为开启

open-baidudx=0

百度云短信接口AK(ACCESS_KEY_ID)

BDY_DX_AK=xxxxx

百度云短信接口SK(SECRET_ACCESS_KEY)

BDY_DX_SK=xxxxx

百度云短信ENDPOINT(ENDPOINT参数需要用指定区域的域名来进行定义,如服务所在区域为北京,则为)

BDY_DX_ENDPOINT=http://smsv3.bj.baidubce.com

百度云短信模版ID,根据自己审核通过的模版来填写(模版支持一个参数code:如prometheus告警:{code})

BDY_DX_TEMPLATE_ID=xxxxx

百度云短信签名ID,根据自己审核通过的签名来填写

TXY_DX_SIGNATURE_ID=xxxxx

---------------------↓百度Hi(如流)-----------------------

是否开启百度Hi(如流)告警通道,可同时开始多个通道0为关闭,1为开启

open-ruliu=0

默认百度Hi(如流)机器人地址

BDRL_URL=https://api.im.baidu.com/api/msg/groupmsgsend?access_token=xxxxxxxxxxxxxx

百度Hi(如流)群ID

BDRL_ID=123456

------------------ 原始邮件 ------------------ 发件人: "feiyu563/PrometheusAlert" @.>; 发送时间: 2021年7月13日(星期二) 中午12:52 @.>; @.**@.>; 主题: Re: [feiyu563/PrometheusAlert] 告警测试问题:报错beego application error (#129)

配置文件用不到的配一张不能删除,另外确认下你的配置文件名是不是app.conf

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

feiyu563 commented 3 years ago

proxy是给无法访问外网环境使用的,一般情况不要配置