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


前言

近期,邮件告警通知无法送达,导致部分错误信息开发人员没有及时收到,触发了手动电话通知机制(客户,你懂得)。这个锅我背,之前好好的,突然前段时间就不好使了(脚本什么的并没有动过)。快周末了,重新调整了一下告警通知,顺便加入钉钉机器人监控报警。

服务配置

服务器:192.168.1.180
访问地址:http://logs.52itstyle.com

相关软件

ELK(ElasticSearch、Logstash、Kibana)、Nginx、sendmail、钉钉

告警通知

邮件 + 钉钉通知

logstash 脚本:

input {
        redis {
                host => "192.168.1.180"
                port => 6379
                data_type => "list"
                key => "logstash-tomcat-error"
                type => "redis-input"
                password => "123456"
                db => 0
        }
}
output {
        elasticsearch {
               hosts => ["192.168.1.180:9200"]
        }
        exec {
            command  =>  "/home/logs/script/alarm.sh  %{type} %{message} %{path}"
        }
}
  • message:详细错误日志信息
  • type:项目名称标识
  • path:日志文件路径

告警脚本 alarm.sh:

#!/bin/sh
curl 'https://oapi.dingtalk.com/robot/send?access_token=*************' \
   -H 'Content-Type: application/json' \
   -d '
  {"msgtype": "text",
    "text": {
        "content":"'$1':错误预警,请登录日志平        "content":"'$1':错误预警,请登录日志平监控查看 http://logs.52itstyle.com"
监控查看 http://logs.52itstyle.com"
     }
  }'echo  $3 $1:$2 | mail -s  凌晨一点的bug,就知道养生  [email protected] [email protected]

钉钉告警

钉钉监控

钉钉监控

注意事项

  • linux shell多条命令使用;分隔
  • linux shell中curl发送post请求json,数据里变量要用''括起来

  • 钉钉机器人,对于message信息处理不友好,空格以后的文本会被截取,暂且使用邮件通知

文章来源:原文链接

猜你喜欢

转载自blog.csdn.net/qq_31463999/article/details/80981187