feature(web): 增加日志查看组件
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
package com.lanyuanxiaoyao.service.web.controller;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import com.lanyuanxiaoyao.service.configuration.entity.AmisResponse;
|
||||
import com.lanyuanxiaoyao.service.configuration.entity.loki.LokiLogLine;
|
||||
import com.lanyuanxiaoyao.service.forest.service.LokiService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 日志相关
|
||||
*
|
||||
* @author lanyuanxiaoyao
|
||||
* @date 2023-05-25
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("log")
|
||||
public class LogController extends BaseController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(LogController.class);
|
||||
|
||||
private final LokiService lokiService;
|
||||
|
||||
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
||||
public LogController(LokiService lokiService) {
|
||||
this.lokiService = lokiService;
|
||||
}
|
||||
|
||||
@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())
|
||||
.build())
|
||||
.collect(LokiLogLine::getData)
|
||||
.collect(line -> line.replaceAll(":\\n", ""))
|
||||
.collect(line -> line.replaceAll("\\n$", ""))
|
||||
.collect(line -> line.replaceAll("^\\s*(.+)\\s*#@#\\s*(.+)\\s*$", "$1: $2"))
|
||||
.makeString("\n"));
|
||||
}
|
||||
|
||||
@GetMapping("query_compaction_log")
|
||||
public AmisResponse queryCompactionLog(@RequestParam("flink_job_id") Long flinkJobId, @RequestParam("alias") String alias) {
|
||||
return responseDetail(lokiService.queryRange(MapUtil.<String, String>builder()
|
||||
.put("app", "hudi-sync")
|
||||
.put("run_type", "compaction")
|
||||
.put("flink_job_id", flinkJobId.toString())
|
||||
.put("alias", alias)
|
||||
.build())
|
||||
.collect(LokiLogLine::getData)
|
||||
.collect(line -> line.replaceAll(":\\n", ""))
|
||||
.collect(line -> line.replaceAll("\\n$", ""))
|
||||
.collect(line -> line.replaceAll("^\\s*(.+?)\\s*#@#\\s*(.+?)\\s*$", "$1: $2"))
|
||||
.makeString("\n"));
|
||||
}
|
||||
}
|
||||
29
service-web/src/main/resources/static/components/log-tab.js
Normal file
29
service-web/src/main/resources/static/components/log-tab.js
Normal file
@@ -0,0 +1,29 @@
|
||||
function logTab() {
|
||||
return {
|
||||
title: '运行中',
|
||||
tab: [
|
||||
{
|
||||
type: 'service',
|
||||
api: {
|
||||
method: 'GET',
|
||||
url: '${base}/log/query_compaction_log',
|
||||
data: {
|
||||
flink_job_id: '1646351885991305217',
|
||||
alias: 'dz_mb_sys_login_log',
|
||||
}
|
||||
},
|
||||
body: [
|
||||
{
|
||||
disabled: true,
|
||||
type: 'editor',
|
||||
name: 'detail',
|
||||
label: '压缩日志',
|
||||
options: {
|
||||
wordWrap: 'on',
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@
|
||||
<script src="components/cloud-tab.js"></script>
|
||||
<script src="components/queue-tab.js"></script>
|
||||
<script src="components/running-tab.js"></script>
|
||||
<script src="components/log-tab.js"></script>
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
let amis = amisRequire('amis/embed')
|
||||
@@ -53,6 +54,7 @@
|
||||
unmountOnExit: true,
|
||||
tabsMode: 'strong',
|
||||
tabs: [
|
||||
// logTab(),
|
||||
// runningTab(),
|
||||
tableTab(),
|
||||
queueTab(),
|
||||
|
||||
Reference in New Issue
Block a user