logstash获取异常日志推送钉钉

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了logstash获取异常日志推送钉钉相关的知识,希望对你有一定的参考价值。

logstash.conf配置
input {
file {
path => "/data/home/services/xxx/logs/xxx.log"
#path => "/opt/test.log"
#设置logstash开始读取文件内容位置,begining为从头开始,end为只读取最新数据
start_position => "end"
}
}

output {
if ‘"errorCode":1306‘ in [message] {
#stdout { codec => rubydebug }
http {
url => "https://oapi.dingtalk.com/robot/send?access_token=xxx"
http_method => "post"
content_type => "application/json; charset=utf-8"
format => "message"
message => ‘{"msgtype":"text","text":{"content": "音视频播放异常: service:xxx ip:172.17.8.226 APP_LOG errcode is 1306"}}‘
}
}else if ‘"errorCode" : "1307"‘ in [message] {
http {
url => "https://oapi.dingtalk.com/robot/send?access_token=xx"
http_method => "post"
content_type => "application/json; charset=utf-8"
format => "message"
message => ‘{"msgtype":"text","text":{"content": "音视频播放异常: service:xx-api ip:172.17.8.226 APP_LOG errcode is 1307"}}‘
}
}
}

以上是关于logstash获取异常日志推送钉钉的主要内容,如果未能解决你的问题,请参考以下文章

ELK日志监控平台告警升级(邮件+钉钉)

pinpoint实现告警推送至钉钉和微信群

ELK日志分析系统(实例!!!)

ELK 日志分析系统

elk/elasticsearch+fluentd+kibana

Logstash 常用 filter 插件介绍