pinpoint-batch-2.3.3-邮件告警配置

目录

一、安装环境准备

二、alarm功能数据库用户和表创建

三、更新或新增pinpoint-batch-2.3.3.jar相关配置文件

四、启动pinpoint-batch服务

五、配置alarm邮件告警

六、调试过程中遇到问题以及处理


一、安装环境准备

  • pinpoint-batch-2.3.3.jar
  • mysql-5.7.34

二、alarm功能数据库用户和表创建

alarm功能官方说明文档:

pinpoint/alarm.md at 2.3.x · pinpoint-apm/pinpoint · GitHub

1.pinpoint-collector、pinpoint-web、pinpoint-agent的安装可参考:

https://xdong.blog.csdn.net/article/details/123180298

2.Pinpoint的alarm功能需要MySQL服务,安装mysql可参考网上mysql数据库安装步骤

3.创建db和相关用户和数据库表

alarm功能连数据库jar包中默认配置:

pinpoint-web-boot-2.3.3.jar\BOOT-INF\classes\jdbc-root.properties

配置项(可根据实际情况修改):

jdbc.url=jdbc:mysql://localhost:13306/pinpoint

jdbc.username=admin

jdbc.password=admin

建库,用户,授权:

create database pinpoint default character set utf8 collate utf8_general_ci;

create user admin@'%' identified by 'admin';

grant all on pinpoint.* to 'admin'@'%';

grant REFERENCES on pinpoint.* to  admin@'%';

FLUSH PRIVILEGES;

4.创建相关数据库表文件:

pinpoint-web-boot-2.3.3.jar\BOOT-INF\classes\sql\CreateTableStatement-mysql.sql

pinpoint-web-boot-2.3.3.jar\BOOT-INF\classes\sql\SpringBatchJobRepositorySchema-mysql.sql

更新或新增pinpoint-batch-2.3.3.jar相关配置文件

相关邮件发送的配置在配置文件:

pinpoint-batch-2.3.3.jar\BOOT-INF\classes\batch-root.properties

可以修改配置文件,也可以在外部创建配置文件并设置配置项进行覆盖,启动时候引用。

创建外部配置文件:

/opt/pinpoint/config/pinpoint-batch.properties

配置项:

#启动pinpoint-batch-2.3.3.jar时报错找不到zk地址,添加该配置项

pinpoint.zookeeper.address=192.168.1.2:2181

#启动jar包时报错,添加该配置项

spring.main.allow-bean-definition-overriding=true

#smtp 配置项目

#配置pinpoint-web的网址,在发送的邮箱内容里面会发送相关的pinpoint网址链接

pinpoint.url=http://192.168.1.2:8080

#邮箱服务器配置(提前验证防火墙是否通)

alarm.mail.server.url=mail.xxx.com

#邮件发送一般使用的端口是SMTP协议的25端口。但现在很多邮件服务商也支持SSL加密的SMTP协议的SSL加密的465端口或TLS加密的587,以提高邮件传输的安全性

#几个端口都试试,多次尝试后配置25端口才成功

alarm.mail.server.port=25

#server.username和sender.address保持一致,设置发送邮件的邮箱地址

alarm.mail.server.username=xxx@xxxx.com

alarm.mail.server.password=pwd

alarm.mail.sender.address=xxx@xxxx.com

#25端口是未加密邮件端口

alarm.mail.transport.protocol=smtp

alarm.mail.smtp.port=25

alarm.mail.smtp.auth=false

alarm.mail.smtp.starttls.enable=false

alarm.mail.smtp.starttls.required=false

#邮件发送调试模式,再刚开始验证时可设置为true

alarm.mail.debug=true

启动pinpoint-batch服务

启动命令:

nohup java -Dspring.profiles.active=release -Dspring.config.location=/opt/pinpoint/config/pinpoint-batch.properties  -jar /opt/pinpoint/pinpoint-batch-2.3.3.jar --server.port=8088 >/opt/pinpoint/logs/pinpoint-batch.log 2>&1 &

停止服务命令:

ps -ef | grep pinpoint-batch | grep -v grep | awk '{print $2}' | xargs kill -9

启动命令说明:

-Dspring.profiles.active=release  ------  选择配置文件目录,在jar包的pinpoint-batch-2.3.3.jar\BOOT-INF\classes\profiles\目录下

-Dspring.config.location=/opt/pinpoint/config/pinpoint-batch.properties ------ 启动本地配置文件

--server.port=8088 ------ 服务启动使用端口

配置alarm邮件告警

在pinpoint-web的后台设置页面进行设置http://192.168.1.2:8080/config/

1.设置用户组

2.添加用户

3.人员信息维护

维护邮箱地址信息:

4.告警规则设置

六、调试过程中遇到问题以及处理

1. pinpoint-batch的扫描频率设置

在配置文件:

pinpoint-batch-2.3.3.jar\BOOT-INF\classes\applicationContext-batch-schedule.xml

pinpoint批处理服务器默认设置是每3分钟检查一次数据,并基于最近5分钟的数据进行判断。如果满足条件,则会向用户组中列出的用户发送短信/电子邮件/webhook

如果每次超过阈值都发送电子邮件/短信/webhook,则可能导致告警消息被频繁发送,因此系统会逐渐增加告警的传输频率。

例如,如果连续发生告警,则将传输频率增加两倍。 3分钟->6分钟->12分钟->24分钟

    <task:scheduled-tasks scheduler="scheduler">

        <task:scheduled ref="batchJobLauncher" method="alarmJob" cron="0 0/3 * * * *"/>

        <task:scheduled ref="batchJobLauncher" method="agentCountJob" cron="0 0 2 * * *"/>

        <task:scheduled ref="batchJobLauncher" method="flinkCheckJob" cron="0 0/10 * * * *"/>

        <task:scheduled ref="batchJobLauncher" method="cleanupInactiveAgentsJob" cron="#{batchConfiguration['cleanupInactiveAgentsCron']}"/>

    </task:scheduled-tasks>

2. 使用官方文档中的启动命令来启动pinpoint-batch,会报找不到zk地址

官方启动命令:

java -Dspring.profiles.active=local -jar /opt/pinpoint/pinpoint-batch-2.3.3.jar

更新后启动命令:

nohup java -Dspring.profiles.active=release -jar /opt/pinpoint/pinpoint-batch-2.3.3.jar >/opt/pinpoint/logs/pinpoint-batch.log 2>&1 &

报错信息:

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'pinpoint.zookeeper.address' in value "${pinpoint.zookeeper.address}"

异常表示在读取包含 ${...} 占位符的配置文件时,Spring 无法解析该占位符。这通常是由于没有正确导入包含该占位符的配置文件或者没有正确配置属性来源所致

解决方法:

在pinpoint-batch.properties外部的配置文件中添加ZK的配置项:

pinpoint.zookeeper.address=192.168.1.2:2181

3. 增加了ZK的配置项启动后,还是报错

启动命令:

nohup java -Dspring.profiles.active=release -Dspring.config.location=/opt/pinpoint/config/pinpoint-batch.properties  -jar /opt/pinpoint/pinpoint-batch-2.3.3.jar >/opt/pinpoint/logs/pinpoint-batch.log 2>&1 &

报错信息:

The bean 'reader', defined in BeanDefinition defined in class path resource [job/applicationContext-alarmJob.xml], could not be registered.

A bean with that name has already been defined in class path resource [job/applicationContext-alarmJob.xml] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

这个错误通常出现在同一应用程序中定义了多个相同名称的 Spring Bean,并且没有开启覆盖(override)选项。在您的情况下, reader 这个 Bean 在 job/applicationContext-alarmJob.xml 文件中被定义了多次,因此导致了该错误。

解决方法:

根据action的提示信息,在pinpoint-batch.properties外部的配置文件中添加配置项:

spring.main.allow-bean-definition-overriding=true

4. 问题23解决后,启动服务,又提示端口被占用了

报错信息:

Web server failed to start. Port 8080 was already in use.

解决方法:

在启动命令中指定服务的端口:

 --server.port=8088

5.解决上面三个问题后,pinpoint-batch服务终于可以正常启动了,后面大部分排错问题是一直无法连接到邮件服务器。

jar包里面的默认配置为:

#smtp config

pinpoint.url=

alarm.mail.server.url=

alarm.mail.server.port=587

alarm.mail.server.username=

alarm.mail.server.password=

alarm.mail.sender.address=pinpoint_operator@pinpoint.com

alarm.mail.transport.protocol=smtp

alarm.mail.smtp.port=25

alarm.mail.smtp.auth=false

alarm.mail.smtp.starttls.enable=false

alarm.mail.smtp.starttls.required=false

alarm.mail.debug=false

刚开始设置的配置:

alarm.mail.server.url=mail.xxxx.com

alarm.mail.server.port=465

alarm.mail.server.username=xxx@xxxx.com

alarm.mail.server.password=pwd

alarm.mail.sender.address=xxx@xxxx.com

alarm.mail.transport.protocol=smtp

alarm.mail.smtp.port=25

alarm.mail.smtp.auth=false

alarm.mail.smtp.starttls.enable=false

alarm.mail.smtp.starttls.required=false

alarm.mail.debug=true

提示无法连接上邮箱服务器,根据查询资料465端口是SSL加密的,所以把下面三个设置都设置成true

alarm.mail.smtp.auth=true

alarm.mail.smtp.starttls.enable=true

alarm.mail.smtp.starttls.required=true

结果还是一样

然后就是各种调试配置项,后面仔细看了下日志,无论调整哪个配置,都提示isSSL false,于是将端口替换成25后,居然成功了。

补充:最近看了下pinpoint的github配置文件说明,在2.5版本后的pinpoint-batch的batch-root.properties配置文件才有ssl的配置:

spring.mail.properties.mail.smtp.ssl.enable=false

之前的版本没看到有参数来调整。

alarm.mail.server.url=mail.xxxx.com

alarm.mail.server.port=25

alarm.mail.server.username=xxx@xxxx.com

alarm.mail.server.password=pwd

alarm.mail.sender.address=xxx@xxxx.com

alarm.mail.transport.protocol=smtp

alarm.mail.smtp.port=25

alarm.mail.smtp.auth=false

alarm.mail.smtp.starttls.enable=false

alarm.mail.smtp.starttls.required=false

alarm.mail.debug=true

        isSSL false 提示信息意味着您未启用 SSL/HTTPS 支持。在 Pinpoint-batch 的系统环境变量中,该设置默认为 false

      上述问题解决后,终于配置好了pinpoint的邮件告警,希望对大家有所帮助。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值