From b8607dbdc491520c3c6732e51b60e3609f1920f2 Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Sun, 4 Feb 2024 16:37:40 +0800 Subject: [PATCH] =?UTF-8?q?feat(loki-query):=20=E7=A7=BB=E9=99=A4loki-quer?= =?UTF-8?q?y=E9=83=A8=E7=BD=B2=20=E9=A1=B5=E9=9D=A2=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E8=B7=B3=E8=BD=ACgrafana?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 12 ----- .../service/web/controller/LogController.java | 53 +------------------ .../resources/static/components/log-tab.js | 29 ---------- .../src/main/resources/static/extra.html | 1 - .../src/main/resources/static/index.html | 1 - 5 files changed, 1 insertion(+), 95 deletions(-) delete mode 100644 service-web/src/main/resources/static/components/log-tab.js diff --git a/service-cli/service-cli-runner/src/main/resources/application.yml b/service-cli/service-cli-runner/src/main/resources/application.yml index f605fc1..b10e9a7 100644 --- a/service-cli/service-cli-runner/src/main/resources/application.yml +++ b/service-cli/service-cli-runner/src/main/resources/application.yml @@ -97,18 +97,6 @@ deploy: - name: service-info-query source-jar: service-info-query-1.0.0-SNAPSHOT.jar replicas: 10 - - name: service-loki-query - source-jar: service-loki-query-1.0.0-SNAPSHOT.jar - replicas: 5 - arguments: - spring_application_name: service-loki-query - loki_host: ${deploy.runtime.loki.service-url} - - name: service-loki-hudi-query - source-jar: service-loki-query-1.0.0-SNAPSHOT.jar - replicas: 10 - arguments: - spring_application_name: service-loki-hudi-query - loki_host: ${deploy.runtime.loki.hudi-url} - name: service-yarn-query source-jar: service-yarn-query-1.0.0-SNAPSHOT.jar replicas: 20 diff --git a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/LogController.java b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/LogController.java index 43b1cb4..5d4ad3e 100644 --- a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/LogController.java +++ b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/LogController.java @@ -1,18 +1,13 @@ package com.lanyuanxiaoyao.service.web.controller; -import cn.hutool.core.map.MapUtil; -import com.lanyuanxiaoyao.service.configuration.entity.loki.LokiLogLine; import com.lanyuanxiaoyao.service.forest.service.InfoService; -import com.lanyuanxiaoyao.service.forest.service.loki.LokiHudiService; import com.lanyuanxiaoyao.service.web.controller.base.AmisCrudResponse; -import com.lanyuanxiaoyao.service.web.controller.base.AmisDetailResponse; import com.lanyuanxiaoyao.service.web.controller.base.AmisResponse; import com.lanyuanxiaoyao.service.web.controller.base.BaseController; 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; /** @@ -26,59 +21,13 @@ import org.springframework.web.bind.annotation.RestController; public class LogController extends BaseController { private static final Logger logger = LoggerFactory.getLogger(LogController.class); - private final LokiHudiService lokiHudiService; private final InfoService infoService; @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") - public LogController(LokiHudiService lokiHudiService, InfoService infoService) { - this.lokiHudiService = lokiHudiService; + public LogController(InfoService infoService) { this.infoService = infoService; } - private String preHandle(String line) { - return line - .replaceAll("\\n$", "") - .replaceAll("^\\s*(.+?)\\s*#@# :\\s*(.+?)\\s*$", "$1: $2"); - } - - @GetMapping("query_sync_log") - public AmisDetailResponse querySyncLog(@RequestParam("flink_job_id") Long flinkJobId) { - return AmisResponse.responseDetailData(lokiHudiService.queryRange(MapUtil.builder() - .put("app", "hudi-sync") - .put("run_type", "sync") - .put("flink_job_id", flinkJobId.toString()) - .put("limit", "1000") - .build()) - .collect(LokiLogLine::getData) - .collect(this::preHandle) - .makeString("\n")); - } - - @GetMapping("query_compaction_log") - public AmisDetailResponse queryCompactionLog(@RequestParam("flink_job_id") Long flinkJobId, @RequestParam("alias") String alias) { - return AmisResponse.responseDetailData(lokiHudiService.queryRange(MapUtil.builder() - .put("app", "hudi-sync") - .put("run_type", "compaction") - .put("flink_job_id", flinkJobId.toString()) - .put("alias", alias) - .put("limit", "1000") - .build()) - .collect(LokiLogLine::getData) - .collect(this::preHandle) - .makeString("\n")); - } - - @GetMapping("query_application_log") - public AmisDetailResponse queryApplicationLog(@RequestParam("application_id") String applicationId) { - return AmisResponse.responseDetailData(lokiHudiService.queryRange(MapUtil.builder() - .put("app_id", applicationId) - .put("limit", "1000") - .build()) - .collect(LokiLogLine::getData) - .collect(this::preHandle) - .makeString("\n")); - } - @GetMapping("query_sql_log") public AmisCrudResponse querySQLLog() { return AmisResponse.responseCrudData(infoService.sqlLogs()); diff --git a/service-web/src/main/resources/static/components/log-tab.js b/service-web/src/main/resources/static/components/log-tab.js deleted file mode 100644 index 80fe0af..0000000 --- a/service-web/src/main/resources/static/components/log-tab.js +++ /dev/null @@ -1,29 +0,0 @@ -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', - } - } - ] - }, - ], - } -} \ No newline at end of file diff --git a/service-web/src/main/resources/static/extra.html b/service-web/src/main/resources/static/extra.html index 2614255..6d5ed23 100644 --- a/service-web/src/main/resources/static/extra.html +++ b/service-web/src/main/resources/static/extra.html @@ -41,7 +41,6 @@ - diff --git a/service-web/src/main/resources/static/index.html b/service-web/src/main/resources/static/index.html index 4378b30..7129055 100644 --- a/service-web/src/main/resources/static/index.html +++ b/service-web/src/main/resources/static/index.html @@ -41,7 +41,6 @@ -