pinpoint 监控mysql_【APM】Pinpoint 监控告警(三)

本例介绍Pinpoint告警的相关内容,Pinpoint参考【APM】Pinpoint 安装部署(一)

Pinpoint Web会定期检查应用程序的状态,并在满足某些预配置条件(规则)的情况下触发警报。

这些条件(默认情况下)由Web模块中的后台批处理过程每3分钟检查一次(默认情况下),使用的是最后5分钟的数据。一旦满足条件,批处理过程就会向注册到用户组的用户发送短信/电子邮件。

Pinpoint告警原理

1、下载源码,通过源码解析:

Pinpoint中有一个匹处理类,BatchConfiguration.java,此类会进行批任务处理

1 @Configuration2 @Conditional(BatchConfiguration.Condition.class)3 @ImportResource("classpath:/batch/applicationContext-batch-schedule.xml")4 public classBatchConfiguration{5 static class Condition implementsConfigurationCondition {6 @Override7 public booleanmatches(ConditionContext context, AnnotatedTypeMetadata metadata) {8 ......9 Resource resource = context.getResourceLoader().getResource("classpath:/batch.properties")10 ......11 final String enable = properties.getProperty("batch.enable");12 ......13 }14 }15 }

Condition中会读取配置文件batch.properties中的配置项batch.enable,默认是false。因此如果要开启批处理功能,必须设置batch.enable=true。

2、在Pinpoint中,在批处理任务配置文件(applicationContext-batch-schedule.xml)中,文件路径为:pinpoint/web/src/main/resources/batch/applicationContext-batch-schedule.xml,可以找到定义的任务

1

2

3

4

5

6

7

配置文件中,定义了执行告警Job的时间。定义了一个线程池大小为1的调度器scheduler

3、在Pinpoint中,在告警任务配置文件(applicationContext-alarmJob.xml)中,文件路径为:pinpoint/web/src/main/resources/batch/applicationContext-alarmJob.xml,

reader:读取数据 => 通过用户配置的规则提供Checker,即异常校验器。

processor:处理数据 => 用Checker进行校验,标记异常状态。

writer:回写数据 => 判断Checker是否有异常情况,有则报警。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

4、在回写数据类中AlarmWriter.java中发现,是通过注入AlarmMessageSender来发送消息

1 public class AlarmWriter implements ItemWriter{2

3 @Autowired(required = false)4 private AlarmMessageSender alarmMessageSender = newEmptyMessageSend

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值