Skip to content

Commit

Permalink
[Feature][Server] Notification info add job view link (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
735140144 authored May 31, 2024
1 parent a6ed566 commit 60dc63f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bin/datavines-daemon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ case $startStop in

esac

echo "End $startStop DataVinesServer $profile."
echo "End $startStop DataVinesServer $profile."
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ public class CommonPropertyUtils {
public static final String FILE_MAX_LENGTH = "file.max.length";
public static final Long FILE_MAX_LENGTH_DEFAULT = 10 * 1024 * 1024L;

public static final String DATAVINES_FQDN = "datavines.fqdn";
public static final String DATAVINES_FQDN_DEFAULT = "http://127.0.0.1:5600";

private static final Logger logger = LoggerFactory.getLogger(CommonPropertyUtils.class);

public static final String COMMON_PROPERTIES_PATH = "/common.properties";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import io.datavines.common.entity.JobExecutionRequest;
import io.datavines.common.enums.OperatorType;
import io.datavines.common.utils.CommonPropertyUtils;
import io.datavines.common.utils.JSONUtils;
import io.datavines.common.utils.ParameterUtils;
import io.datavines.common.utils.StringUtils;
Expand Down Expand Up @@ -61,7 +62,7 @@ public class JobResultValidator {

@Autowired
private IssueService issueService;

/**
* When the task type is data quality, it will get the statistics value、comparison value、
* threshold、check type、operator and failure strategy,use the formula that
Expand Down Expand Up @@ -127,6 +128,7 @@ private void sendErrorEmail(Long jobExecutionId) {
String jobName;
String dataSourceName = null;
String dataSourceType = null;
String fqdn= "";
if (jobId == -1L) {
jobName = jobExecution.getName();
} else {
Expand All @@ -137,6 +139,9 @@ private void sendErrorEmail(Long jobExecutionId) {
DataSource dataSource = jobExternalService.getDataSourceService().getDataSourceById(dataSourceId);
dataSourceName = dataSource.getName();
dataSourceType = dataSource.getType();
if (!CommonPropertyUtils.getString(CommonPropertyUtils.DATAVINES_FQDN).equals(CommonPropertyUtils.DATAVINES_FQDN_DEFAULT)) {
fqdn = CommonPropertyUtils.getString(CommonPropertyUtils.DATAVINES_FQDN) + String.format("/#/main/detail/%s/jobs/instance?jobId=%s", dataSourceId, jobId);
}
}

List<JobExecutionResult> errorJobExecutionResultList = jobExternalService.listErrorJobExecutionResultByJobExecutionId(jobExecution.getId());
Expand All @@ -154,7 +159,7 @@ private void sendErrorEmail(Long jobExecutionId) {
messages.add(String.format((isEn ? "Datasource : %s [%s] : ": "数据源 : %s [%s]: ") ,dataSourceType.toUpperCase(), dataSourceName));
}
String title = buildAlertSubject(metricExecutionResult, isEn);
String content = buildAlertMessage(messages, metricExecutionResult, jobExecution.getEngineType(), isEn);
String content = buildAlertMessage(messages, metricExecutionResult,fqdn, jobExecution.getEngineType(), isEn);
message.setSubject(title);
message.setMessage(content);
saveIssue(jobId, title, content);
Expand All @@ -170,7 +175,7 @@ private void sendErrorEmail(Long jobExecutionId) {
}
}

private String buildAlertMessage(List<String> messages, MetricExecutionResult metricExecutionResult, String engineType, boolean isEn) {
private String buildAlertMessage(List<String> messages, MetricExecutionResult metricExecutionResult,String fqdn, String engineType, boolean isEn) {
Map<String,String> parameters = new HashMap<>();
parameters.put("actual_value", String.valueOf(metricExecutionResult.getActualValue()));
parameters.put("expected_value", String.valueOf(metricExecutionResult.getExpectedValue()));
Expand All @@ -193,6 +198,10 @@ private String buildAlertMessage(List<String> messages, MetricExecutionResult me

messages.add(isEn ? "Check Result : Failure" : "检查结果 : 异常" );

if (StringUtils.isNotEmpty(fqdn)){
messages.add((isEn ? "Task Execution Record":"任务执行记录") + " : " + fqdn);
}

return JSONUtils.toJsonString(messages);
}

Expand Down
1 change: 1 addition & 0 deletions scripts/sql/datavines-mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,7 @@ INSERT INTO `dv_config` VALUES ('26', '-1', 'spark.engine.parameter.driver.cores
INSERT INTO `dv_config` VALUES ('27', '-1', 'spark.engine.parameter.driver.memory', '512M', '1', '1', '2023-09-05 21:02:38', '1', '2023-09-05 21:02:38');
INSERT INTO `dv_config` VALUES ('28', '-1', 'spark.engine.parameter.executor.cores', '1', '1', '1', '2023-09-05 21:02:38', '1', '2023-09-05 21:02:38');
INSERT INTO `dv_config` VALUES ('29', '-1', 'spark.engine.parameter.executor.memory', '512M', '1', '1', '2023-09-05 21:02:38', '1', '2023-09-05 21:02:38');
INSERT INTO `dv_config` VALUES ('30', '-1', 'datavines.fqdn', 'http://127.0.0.1:5600', '1', '1', '2024-05-21 15:15:38', '1', '2024-05-21 15:15:38');

INSERT INTO `dv_user` (`id`, `username`, `password`, `email`, `phone`, `admin`) VALUES ('1', 'admin', '$2a$10$9ZcicUYFl/.knBi9SE53U.Nml8bfNeArxr35HQshxXzimbA6Ipgqq', '[email protected]', NULL, '0');
INSERT INTO `dv_workspace` (`id`, `name`, `create_by`, `update_by`) VALUES ('1', "admin\'s default", '1', '1');
Expand Down

0 comments on commit 60dc63f

Please sign in to comment.