refactor(web): 优化日志查看
This commit is contained in:
@@ -29,17 +29,22 @@ public class LogController extends BaseController {
|
||||
this.lokiService = lokiService;
|
||||
}
|
||||
|
||||
private String preHandle(String line) {
|
||||
return line
|
||||
.replaceAll("\\n$", "")
|
||||
.replaceAll("^\\s*(.+?)\\s*#@# :\\s*(.+?)\\s*$", "$1: $2");
|
||||
}
|
||||
|
||||
@GetMapping("query_sync_log")
|
||||
public AmisResponse querySyncLog(@RequestParam("flink_job_id") Long flinkJobId) {
|
||||
return responseDetail(lokiService.queryRange(MapUtil.<String, String>builder()
|
||||
.put("app", "hudi-sync")
|
||||
.put("run_type", "sync")
|
||||
.put("flink_job_id", flinkJobId.toString())
|
||||
.put("limit", "1000")
|
||||
.build())
|
||||
.collect(LokiLogLine::getData)
|
||||
.collect(line -> line.replaceAll(":\\n", ""))
|
||||
.collect(line -> line.replaceAll("\\n$", ""))
|
||||
.collect(line -> line.replaceAll("^\\s*(.+)\\s*#@#\\s*(.+)\\s*$", "$1: $2"))
|
||||
.collect(this::preHandle)
|
||||
.makeString("\n"));
|
||||
}
|
||||
|
||||
@@ -50,11 +55,21 @@ public class LogController extends BaseController {
|
||||
.put("run_type", "compaction")
|
||||
.put("flink_job_id", flinkJobId.toString())
|
||||
.put("alias", alias)
|
||||
.put("limit", "1000")
|
||||
.build())
|
||||
.collect(LokiLogLine::getData)
|
||||
.collect(line -> line.replaceAll(":\\n", ""))
|
||||
.collect(line -> line.replaceAll("\\n$", ""))
|
||||
.collect(line -> line.replaceAll("^\\s*(.+?)\\s*#@#\\s*(.+?)\\s*$", "$1: $2"))
|
||||
.collect(this::preHandle)
|
||||
.makeString("\n"));
|
||||
}
|
||||
|
||||
@GetMapping("query_application_log")
|
||||
public AmisResponse queryApplicationLog(@RequestParam("application_id") String applicationId) {
|
||||
return responseDetail(lokiService.queryRange(MapUtil.<String, String>builder()
|
||||
.put("app", "hudi-sync")
|
||||
.put("app_id", applicationId)
|
||||
.build())
|
||||
.collect(LokiLogLine::getData)
|
||||
.collect(this::preHandle)
|
||||
.makeString("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,44 @@ function timeAndFrom(field, fromNow, emptyText = '未停止', showSource = true)
|
||||
return tpl
|
||||
}
|
||||
|
||||
function applicationLogDialog() {
|
||||
return {
|
||||
type: 'action',
|
||||
level: 'link',
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
title: '应用日志',
|
||||
size: 'xl',
|
||||
actions: [],
|
||||
body: [
|
||||
{
|
||||
type: 'service',
|
||||
api: {
|
||||
method: 'GET',
|
||||
url: '${base}/log/query_application_log',
|
||||
data: {
|
||||
application_id: '${id}',
|
||||
}
|
||||
},
|
||||
body: [
|
||||
{
|
||||
disabled: true,
|
||||
type: 'editor',
|
||||
name: 'detail',
|
||||
label: '应用日志',
|
||||
size: 'xxl',
|
||||
placeholder: '没有内容',
|
||||
options: {
|
||||
wordWrap: 'on',
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function yarnCrudColumns() {
|
||||
return [
|
||||
{
|
||||
@@ -163,6 +201,10 @@ function yarnCrudColumns() {
|
||||
actionType: 'url',
|
||||
url: '${trackingUrl}',
|
||||
blank: true,
|
||||
},
|
||||
{
|
||||
label: '日志',
|
||||
...applicationLogDialog(),
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user