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
    评论
您好!要在Spring Boot项目中使用Pinpoint进行监控,您需要按照以下步骤进行设置: 1. 首先,您需要在您的Spring Boot项目中添加Pinpoint的依赖。您可以在项目的pom.xml文件中添加以下依赖: ```xml <dependency> <groupId>com.navercorp.pinpoint</groupId> <artifactId>pinpoint-bootstrap</artifactId> <version>${pinpoint.version}</version> </dependency> ``` 确保将`${pinpoint.version}`替换为您要使用的Pinpoint版本。 2. 接下来,您需要在您的Spring Boot应用程序的入口类上添加`@PinpointConfig`注解。这将启用Pinpoint代理,并将其连接到Pinpoint Collector。 ```java import com.navercorp.pinpoint.bootstrap.config.ProfilerConfig; import com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig; import com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig; @PinpointConfig @SpringBootApplication public class YourApplication { public static void main(String[] args) { SpringApplication.run(YourApplication.class, args); } @Bean public ProfilerConfig profilerConfig() { return new DefaultProfilerConfig(); } } ``` 3. 在运行您的Spring Boot应用程序之前,您需要确保Pinpoint Collector正在运行,并且Pinpoint代理可以连接到它。您可以在Pinpoint Collector的管理界面上查看代理的连接情况。 4. 运行您的Spring Boot应用程序,并访问它以触发Pinpoint代理的数据收集。您可以在Pinpoint Collector的管理界面上查看应用程序的监控数据。 这些是在Spring Boot项目中使用Pinpoint进行监控的基本步骤。您还可以根据Pinpoint的文档和配置文件进行更详细的设置和调整。希望对您有所帮助!如有任何问题,请随时向我提问。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值