refactor:2.5.0

1. 优化告警内容
This commit is contained in:
byteblogs168 2023-12-10 10:39:40 +08:00
parent f46337da37
commit 1361c2b248
8 changed files with 28 additions and 9 deletions

View File

@ -19,6 +19,7 @@ import com.aizuda.easy.retry.common.core.enums.RetryResultStatusEnum;
import com.aizuda.easy.retry.common.core.log.LogUtils;
import com.aizuda.easy.retry.common.core.model.EasyRetryHeaders;
import com.aizuda.easy.retry.common.core.util.EnvironmentUtils;
import com.aizuda.easy.retry.common.core.util.HostUtils;
import com.aizuda.easy.retry.server.model.dto.ConfigDTO;
import com.google.common.base.Defaults;
import lombok.extern.slf4j.Slf4j;
@ -48,6 +49,7 @@ public class EasyRetryInterceptor implements MethodInterceptor, AfterAdvice, Ser
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
private static String retryErrorMoreThresholdTextMessageFormatter =
"<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 重试组件异常</font> \n" +
"> IP:{} \n" +
"> 空间ID:{} \n" +
"> 名称:{} \n" +
"> 时间:{} \n" +
@ -205,6 +207,7 @@ public class EasyRetryInterceptor implements MethodInterceptor, AfterAdvice, Ser
AlarmContext context = AlarmContext.build()
.text(retryErrorMoreThresholdTextMessageFormatter,
EnvironmentUtils.getActiveProfile(),
HostUtils.getIp(),
standardEnvironment.getProperty("easy-retry.namespace", StrUtil.EMPTY),
EasyRetryProperties.getGroup(),
LocalDateTime.now().format(formatter),

View File

@ -15,6 +15,7 @@ import com.aizuda.easy.retry.common.core.enums.NotifySceneEnum;
import com.aizuda.easy.retry.common.core.log.LogUtils;
import com.aizuda.easy.retry.common.core.model.NettyResult;
import com.aizuda.easy.retry.common.core.util.EnvironmentUtils;
import com.aizuda.easy.retry.common.core.util.HostUtils;
import com.aizuda.easy.retry.common.core.util.JsonUtil;
import com.aizuda.easy.retry.common.core.window.Listener;
import com.aizuda.easy.retry.server.model.dto.ConfigDTO;
@ -41,7 +42,8 @@ public class ReportListener implements Listener<RetryTaskDTO> {
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
private static String reportErrorTextMessageFormatter =
"<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 异步批量上报异常</font> \n" +
"> 空间ID:{} n" +
"> IP:{} \n" +
"> 空间ID:{} \n" +
"> 名称:{} \n" +
"> 时间:{} \n" +
"> 异常:{} \n"
@ -51,7 +53,6 @@ public class ReportListener implements Listener<RetryTaskDTO> {
.client(NettyClient.class)
.callback(nettyResult -> LogUtils.info(log, "Data report successfully requestId:[{}]", nettyResult.getRequestId())).build();
@Override
public void handler(List<RetryTaskDTO> list) {
RetryExecutor<WaitStrategy, StopStrategy> retryExecutor =
@ -115,6 +116,7 @@ public class ReportListener implements Listener<RetryTaskDTO> {
AlarmContext context = AlarmContext.build()
.text(reportErrorTextMessageFormatter,
EnvironmentUtils.getActiveProfile(),
HostUtils.getIp(),
properties.getNamespace(),
EasyRetryProperties.getGroup(),
LocalDateTime.now().format(formatter),

View File

@ -13,6 +13,7 @@ import com.aizuda.easy.retry.common.core.enums.NotifySceneEnum;
import com.aizuda.easy.retry.common.core.log.LogUtils;
import com.aizuda.easy.retry.common.core.model.NettyResult;
import com.aizuda.easy.retry.common.core.util.EnvironmentUtils;
import com.aizuda.easy.retry.common.core.util.HostUtils;
import com.aizuda.easy.retry.common.core.util.JsonUtil;
import com.aizuda.easy.retry.server.model.dto.ConfigDTO;
import com.aizuda.easy.retry.server.model.dto.RetryTaskDTO;
@ -41,6 +42,7 @@ public class SyncReport extends AbstractReport {
private static String reportErrorTextMessageFormatter =
"<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 同步上报异常</font> \n" +
"> IP:{} \n" +
"> 空间ID:{} \n" +
"> 名称:{} \n" +
"> 时间:{} \n" +
@ -97,6 +99,7 @@ public class SyncReport extends AbstractReport {
AlarmContext context = AlarmContext.build()
.text(reportErrorTextMessageFormatter,
EnvironmentUtils.getActiveProfile(),
HostUtils.getIp(),
easyRetryProperties.getNamespace(),
EasyRetryProperties.getGroup(),
LocalDateTime.now().format(formatter),

View File

@ -15,6 +15,7 @@ import com.aizuda.easy.retry.common.core.alarm.EasyRetryAlarmFactory;
import com.aizuda.easy.retry.common.core.enums.NotifySceneEnum;
import com.aizuda.easy.retry.common.core.log.LogUtils;
import com.aizuda.easy.retry.common.core.util.EnvironmentUtils;
import com.aizuda.easy.retry.common.core.util.HostUtils;
import com.aizuda.easy.retry.server.model.dto.ConfigDTO;
import com.github.rholder.retry.Retryer;
import com.github.rholder.retry.StopStrategy;
@ -41,6 +42,7 @@ public abstract class AbstractRetryStrategies implements RetryStrategy {
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
private static String retryErrorMoreThresholdTextMessageFormatter =
"<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 重试期间发生非预期异常</font> \n" +
"> IP:{} \n" +
"> 空间ID:{} \n" +
"> 名称:{} \n" +
"> 时间:{} \n" +
@ -179,6 +181,7 @@ public abstract class AbstractRetryStrategies implements RetryStrategy {
AlarmContext context = AlarmContext.build()
.text(retryErrorMoreThresholdTextMessageFormatter,
EnvironmentUtils.getActiveProfile(),
HostUtils.getIp(),
easyRetryProperties.getNamespace(),
EasyRetryProperties.getGroup(),
LocalDateTime.now().format(formatter),

View File

@ -7,6 +7,7 @@ import lombok.Getter;
*
* @author: www.byteblogs.com
* @date : 2021-11-24 18:18
* @since : 1.0.0
*/
@Getter
public enum NotifySceneEnum {
@ -19,7 +20,7 @@ public enum NotifySceneEnum {
CLIENT_COMPONENT_ERROR(4,"客户端组件异常", NodeTypeEnum.CLIENT),
RETRY_TASK_REACH_THRESHOLD(5, "任务重试失败数量超过阈值", NodeTypeEnum.SERVER),
RETRY_TASK_REACH_THRESHOLD(5, "任务重试次数超过阈值", NodeTypeEnum.SERVER),
RETRY_TASK_ENTER_DEAD_LETTER(6, "任务重试失败进入死信队列", NodeTypeEnum.SERVER);

View File

@ -49,7 +49,7 @@ public class RetryTaskFailMoreThresholdAlarmListener extends
*/
private LinkedBlockingQueue<RetryTask> queue = new LinkedBlockingQueue<>(1000);
private static String retryTaskFailMoreThresholdMessagesFormatter =
"<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 重试任务失败数量超过阈值</font> \n" +
"<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 任务重试次数超过{}个</font> \n" +
"> 空间ID:{} \n" +
"> 组名称:{} \n" +
"> 执行器名称:{} \n" +
@ -83,6 +83,7 @@ public class RetryTaskFailMoreThresholdAlarmListener extends
// 预警
return AlarmContext.build().text(retryTaskFailMoreThresholdMessagesFormatter,
EnvironmentUtils.getActiveProfile(),
notifyConfig.getNotifyThreshold(),
retryAlarmInfo.getNamespaceId(),
retryAlarmInfo.getGroupName(),
retryAlarmInfo.getExecutorName(),
@ -90,7 +91,7 @@ public class RetryTaskFailMoreThresholdAlarmListener extends
retryAlarmInfo.getRetryCount(),
retryAlarmInfo.getArgsStr(),
DateUtils.format(retryAlarmInfo.getCreateDt(), DateUtils.NORM_DATETIME_PATTERN))
.title("组:[{}] 场景:[{}] 环境重试任务失败数量超过阈值", retryAlarmInfo.getGroupName(),
.title("组:[{}] 场景:[{}] 环境任务重试次数超过阈值", retryAlarmInfo.getGroupName(),
retryAlarmInfo.getSceneName())
.notifyAttribute(notifyConfig.getNotifyAttribute());
}

View File

@ -47,7 +47,8 @@ import java.util.List;
@Slf4j
public class RetryErrorMoreThresholdAlarmSchedule extends AbstractSchedule implements Lifecycle {
private static String retryErrorMoreThresholdTextMessageFormatter =
"<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 重试失败数据监控</font> \n" +
"<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 场景重试失败数量超过{}个</font> \n" +
"> 空间ID:{} \n" +
"> 组名称:{} \n" +
"> 场景名称:{} \n" +
"> 时间窗口:{} ~ {} \n" +
@ -90,11 +91,13 @@ public class RetryErrorMoreThresholdAlarmSchedule extends AbstractSchedule imple
between(RetryDeadLetter::getCreateDt, now.minusMinutes(30), now)
.eq(RetryDeadLetter::getGroupName, notifyConfigPartitionTask.getGroupName())
.eq(RetryDeadLetter::getSceneName, notifyConfigPartitionTask.getSceneName()));
if (count > notifyConfigPartitionTask.getNotifyThreshold()) {
if (count >= notifyConfigPartitionTask.getNotifyThreshold()) {
// 预警
AlarmContext context = AlarmContext.build()
.text(retryErrorMoreThresholdTextMessageFormatter,
EnvironmentUtils.getActiveProfile(),
count,
notifyConfigPartitionTask.getNamespaceId(),
notifyConfigPartitionTask.getGroupName(),
notifyConfigPartitionTask.getSceneName(),
DateUtils.format(now.minusMinutes(30),

View File

@ -44,7 +44,8 @@ import java.util.List;
@RequiredArgsConstructor
public class RetryTaskMoreThresholdAlarmSchedule extends AbstractSchedule implements Lifecycle {
private static String retryTaskMoreThresholdTextMessageFormatter =
"<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 重试数据监控</font> \n" +
"<font face=\"微软雅黑\" color=#ff0000 size=4>{}环境 场景重试数量超过{}个</font> \n" +
"> 空间ID:{} \n" +
"> 组名称:{} \n" +
"> 场景名称:{} \n" +
"> 告警时间:{} \n" +
@ -83,11 +84,13 @@ public class RetryTaskMoreThresholdAlarmSchedule extends AbstractSchedule implem
.eq(RetryTask::getGroupName, partitionTask.getGroupName())
.eq(RetryTask::getSceneName, partitionTask.getSceneName())
.eq(RetryTask::getRetryStatus, RetryStatusEnum.RUNNING.getStatus()));
if (count > partitionTask.getNotifyThreshold()) {
if (count >= partitionTask.getNotifyThreshold()) {
// 预警
AlarmContext context = AlarmContext.build()
.text(retryTaskMoreThresholdTextMessageFormatter,
EnvironmentUtils.getActiveProfile(),
count,
partitionTask.getNamespaceId(),
partitionTask.getGroupName(),
partitionTask.getSceneName(),
DateUtils.toNowFormat(DateUtils.NORM_DATETIME_PATTERN),