diff --git a/server/home/home-alert/src/main/java/io/holoinsight/server/home/alert/service/data/AlarmDataSet.java b/server/home/home-alert/src/main/java/io/holoinsight/server/home/alert/service/data/AlarmDataSet.java index 1c7e33ad3..7cafc5162 100644 --- a/server/home/home-alert/src/main/java/io/holoinsight/server/home/alert/service/data/AlarmDataSet.java +++ b/server/home/home-alert/src/main/java/io/holoinsight/server/home/alert/service/data/AlarmDataSet.java @@ -84,7 +84,7 @@ public void loadData(ComputeTaskPackage computeTaskPackage) { alarmLoadData.queryDataResult(computeTaskPackage, inspectConfig, trigger); trigger.setDataResult(dataResults); } catch (Exception exception) { - LOGGER.error("AlarmLoadData Exception", exception); + LOGGER.error("{} AlarmLoadData Exception", inspectConfig.getTraceId(), exception); RecordSucOrFailNotify.alertNotifyProcessFail("alarm load data Exception: " + exception, ALERT_TASK_COMPUTE, "alarm load data", inspectConfig.getAlertNotifyRecord()); notifySuccess = false; diff --git a/server/home/home-alert/src/main/java/io/holoinsight/server/home/alert/service/data/load/RuleAlarmLoadData.java b/server/home/home-alert/src/main/java/io/holoinsight/server/home/alert/service/data/load/RuleAlarmLoadData.java index be0ee80ea..6967828e3 100644 --- a/server/home/home-alert/src/main/java/io/holoinsight/server/home/alert/service/data/load/RuleAlarmLoadData.java +++ b/server/home/home-alert/src/main/java/io/holoinsight/server/home/alert/service/data/load/RuleAlarmLoadData.java @@ -59,9 +59,10 @@ public List queryDataResult(ComputeTaskPackage computeTask, dataResults = merge(dataResults, deltaResponse); } } catch (Exception exception) { - LOGGER.error("QueryData Exception Request:{} Response:{} DeltaRequest:{} DeltaResponse: {}", - G.get().toJson(request), G.get().toJson(response), G.get().toJson(deltaRequest), - G.get().toJson(deltaResponse), exception); + LOGGER.error( + "{} QueryData Exception Request:{} Response:{} DeltaRequest:{} DeltaResponse: {}", + inspectConfig.getTraceId(), G.get().toJson(request), G.get().toJson(response), + G.get().toJson(deltaRequest), G.get().toJson(deltaResponse), exception); } return dataResults; } diff --git a/server/home/home-facade/src/main/java/io/holoinsight/server/home/facade/trigger/DataSource.java b/server/home/home-facade/src/main/java/io/holoinsight/server/home/facade/trigger/DataSource.java index b13f02446..1767e6504 100644 --- a/server/home/home-facade/src/main/java/io/holoinsight/server/home/facade/trigger/DataSource.java +++ b/server/home/home-facade/src/main/java/io/holoinsight/server/home/facade/trigger/DataSource.java @@ -25,7 +25,7 @@ public class DataSource implements Serializable { private String downsample; // 时间窗口 - private String name; // 代称 (a、b) + private String name = "a"; // 代称 (a、b) private List filters; // 维度筛选 diff --git a/server/home/home-facade/src/main/java/io/holoinsight/server/home/facade/trigger/Trigger.java b/server/home/home-facade/src/main/java/io/holoinsight/server/home/facade/trigger/Trigger.java index 2aa6e177b..8bf36cdff 100644 --- a/server/home/home-facade/src/main/java/io/holoinsight/server/home/facade/trigger/Trigger.java +++ b/server/home/home-facade/src/main/java/io/holoinsight/server/home/facade/trigger/Trigger.java @@ -19,7 +19,7 @@ public class Trigger { private List datasources; - private String query; + private String query = "a"; private String aggregator; diff --git a/server/home/home-service/src/main/java/io/holoinsight/server/home/biz/service/impl/AlertDingDingRobotServiceImpl.java b/server/home/home-service/src/main/java/io/holoinsight/server/home/biz/service/impl/AlertDingDingRobotServiceImpl.java index e9eeed864..ed0d27800 100644 --- a/server/home/home-service/src/main/java/io/holoinsight/server/home/biz/service/impl/AlertDingDingRobotServiceImpl.java +++ b/server/home/home-service/src/main/java/io/holoinsight/server/home/biz/service/impl/AlertDingDingRobotServiceImpl.java @@ -15,6 +15,7 @@ import io.holoinsight.server.home.dal.model.dto.AlarmDingDingRobotDTO; import io.holoinsight.server.home.facade.page.MonitorPageRequest; import io.holoinsight.server.home.facade.page.MonitorPageResult; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -74,8 +75,10 @@ public MonitorPageResult getListByPage( AlarmDingDingRobot alarmDingDingRobot = alarmDingDingRobotConverter.dtoToDO(pageRequest.getTarget()); - this.requestContextAdapter.queryWrapperTenantAdapt(wrapper, alarmDingDingRobot.getTenant(), - alarmDingDingRobot.getWorkspace()); + wrapper.eq("tenant", alarmDingDingRobot.getTenant()); + if (StringUtils.isNotEmpty(alarmDingDingRobot.getWorkspace())) { + wrapper.eq("workspace", alarmDingDingRobot.getWorkspace()); + } if (null != alarmDingDingRobot.getId()) { wrapper.eq("id", alarmDingDingRobot.getId()); diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmSubscribeFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmSubscribeFacadeImpl.java index 336869c41..4a95712c7 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmSubscribeFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmSubscribeFacadeImpl.java @@ -3,16 +3,24 @@ */ package io.holoinsight.server.home.web.controller; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import io.holoinsight.server.common.JsonResult; +import io.holoinsight.server.home.biz.service.AlertSubscribeService; +import io.holoinsight.server.home.biz.ula.ULAFacade; import io.holoinsight.server.home.common.service.RequestContextAdapter; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.common.util.MonitorException; import io.holoinsight.server.home.common.util.ResultCodeEnum; +import io.holoinsight.server.home.common.util.scope.AuthTargetType; +import io.holoinsight.server.home.common.util.scope.MonitorScope; +import io.holoinsight.server.home.common.util.scope.MonitorUser; +import io.holoinsight.server.home.common.util.scope.PowerConstants; +import io.holoinsight.server.home.common.util.scope.RequestContext; import io.holoinsight.server.home.dal.model.AlarmSubscribe; +import io.holoinsight.server.home.dal.model.dto.AlarmSubscribeDTO; import io.holoinsight.server.home.dal.model.dto.AlarmSubscribeInfo; +import io.holoinsight.server.home.web.common.ParaCheckUtil; +import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import io.holoinsight.server.home.web.security.ParameterSecurityService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -26,18 +34,9 @@ import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; -import io.holoinsight.server.common.JsonResult; -import io.holoinsight.server.home.biz.service.AlertSubscribeService; -import io.holoinsight.server.home.biz.ula.ULAFacade; -import io.holoinsight.server.home.common.util.scope.AuthTargetType; -import io.holoinsight.server.home.common.util.scope.MonitorScope; -import io.holoinsight.server.home.common.util.scope.MonitorUser; -import io.holoinsight.server.home.common.util.scope.PowerConstants; -import io.holoinsight.server.home.common.util.scope.RequestContext; -import io.holoinsight.server.home.dal.model.dto.AlarmSubscribeDTO; -import io.holoinsight.server.home.common.util.ManageCallback; -import io.holoinsight.server.home.web.common.ParaCheckUtil; -import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; /** * @author wangsiyuan @@ -108,16 +107,17 @@ public void checkParameter() { if (StringUtils.isNotEmpty(alarmSubscribeDTO.getUniqueId())) { ParaCheckUtil.checkParaBoolean( parameterSecurityService.checkRuleTenantAndWorkspace(alarmSubscribeDTO.getUniqueId(), - ms.getTenant(), ms.getWorkspace()), - "uniqueId do not belong to this tenant or workspace"); + tenant(), workspace()), + "uniqueId do not belong to this tenant " + tenant() + " or workspace " + workspace()); } if (!CollectionUtils.isEmpty(alarmSubscribeDTO.getAlarmSubscribe())) { for (AlarmSubscribeInfo alarmSubscribeInfo : alarmSubscribeDTO.getAlarmSubscribe()) { if (StringUtils.isNotEmpty(alarmSubscribeInfo.getUniqueId())) { ParaCheckUtil.checkParaBoolean( parameterSecurityService.checkRuleTenantAndWorkspace( - alarmSubscribeInfo.getUniqueId(), ms.getTenant(), ms.getWorkspace()), - "uniqueId do not belong to this tenant or workspace"); + alarmSubscribeInfo.getUniqueId(), tenant(), workspace()), + "uniqueId do not belong to this tenant " + tenant() + " or workspace " + + workspace()); } if (CollectionUtils.isEmpty(alarmSubscribeInfo.getNoticeType())) { continue; @@ -147,18 +147,13 @@ public void checkParameter() { @Override public void doManage() { - MonitorScope ms = RequestContext.getContext().ms; MonitorUser mu = RequestContext.getContext().mu; String creator = null; - String tenant = null; if (null != mu) { creator = mu.getLoginName(); } - if (null != ms && !StringUtils.isEmpty(ms.tenant)) { - tenant = ms.tenant; - } boolean rtn = - alarmSubscribeService.saveDataBatch(alarmSubscribeDTO, creator, tenant, ms.workspace); + alarmSubscribeService.saveDataBatch(alarmSubscribeDTO, creator, tenant(), workspace()); JsonResult.createSuccessResult(result, rtn); } }); @@ -178,11 +173,9 @@ public void checkParameter() { @Override public void doManage() { - MonitorScope ms = RequestContext.getContext().ms; QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("unique_id", uniqueId); - requestContextAdapter.queryWrapperTenantAdapt(queryWrapper, ms.getTenant(), - ms.getWorkspace()); + requestContextAdapter.queryWrapperTenantAdapt(queryWrapper, tenant(), workspace()); AlarmSubscribeDTO alarmSubscribeDTO = alarmSubscribeService.queryByUniqueId(queryWrapper, uniqueId); diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MetricInfoFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MetricInfoFacadeImpl.java index b8df384d1..19aa203dc 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MetricInfoFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MetricInfoFacadeImpl.java @@ -9,13 +9,11 @@ import io.holoinsight.server.common.service.MetricInfoService; import io.holoinsight.server.home.biz.plugin.MetricInfoCheckService; import io.holoinsight.server.home.biz.service.IntegrationProductService; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.common.util.scope.AuthTargetType; -import io.holoinsight.server.home.common.util.scope.MonitorScope; import io.holoinsight.server.home.common.util.scope.PowerConstants; -import io.holoinsight.server.home.common.util.scope.RequestContext; import io.holoinsight.server.home.dal.model.dto.IntegrationProductDTO; import io.holoinsight.server.home.task.MetricCrawlerConstant; -import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import org.springframework.beans.factory.annotation.Autowired; @@ -75,9 +73,8 @@ public void checkParameter() { @Override public void doManage() { - MonitorScope ms = RequestContext.getContext().ms; JsonResult.createSuccessResult(result, metricInfoCheckService - .queryMetricInfoByMetricType(ms.getTenant(), ms.getWorkspace(), product.toLowerCase())); + .queryMetricInfoByMetricType(tenant(), workspace(), product.toLowerCase())); } }); return result; @@ -97,7 +94,6 @@ public void checkParameter() { public void doManage() { List metricInfoDTOS = new ArrayList<>(); - MonitorScope ms = RequestContext.getContext().ms; List globalMetrics = metricInfoService.queryListByTenant( MetricCrawlerConstant.GLOBAL_TENANT, MetricCrawlerConstant.GLOBAL_WORKSPACE); @@ -106,7 +102,7 @@ public void doManage() { } List tenantMetrics = - metricInfoService.queryListByTenant(ms.getTenant(), ms.getWorkspace()); + metricInfoService.queryListByTenant(tenant(), workspace()); if (CollectionUtils.isEmpty(tenantMetrics)) { metricInfoDTOS.addAll(tenantMetrics); @@ -130,9 +126,8 @@ public void checkParameter() { @Override public void doManage() { - MonitorScope ms = RequestContext.getContext().ms; MetricInfoDTO metricInfoDTO = - metricInfoService.queryByMetric(ms.getTenant(), ms.getWorkspace(), metric); + metricInfoService.queryByMetric(tenant(), workspace(), metric); JsonResult.createSuccessResult(result, metricInfoDTO); } }); diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/security/custom/AlarmRuleLevelAuthorizationChecker.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/security/custom/AlarmRuleLevelAuthorizationChecker.java index 002159bd0..8b1469d67 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/security/custom/AlarmRuleLevelAuthorizationChecker.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/security/custom/AlarmRuleLevelAuthorizationChecker.java @@ -369,7 +369,7 @@ private LevelAuthorizationCheckResult checkRule(Map ruleMap, Str } if (StringUtils.isNotEmpty(trigger.getTriggerContent()) - && !checkSqlName(trigger.getTriggerContent())) { + && !sqlCnNameCheck(trigger.getTriggerContent())) { return failCheckResult("fail to check triggerContent %s", trigger.getTriggerContent()); }