opt:优化日志查询

This commit is contained in:
zhangzq
2025-03-03 21:26:24 +08:00
parent 70f19e9ce5
commit 4357e8eff6
6 changed files with 50 additions and 24 deletions

View File

@@ -24,21 +24,17 @@ import org.springframework.web.bind.annotation.*;
public class EsLogController { public class EsLogController {
private final EsLogService esLogService; private final EsLogService esLogService;
@GetMapping("/labels/{type}") @GetMapping("/labels/{type}")
public ResponseEntity<Object> labelsValues(@PathVariable String type) { public ResponseEntity<Object> labelsValues(@PathVariable String type) {
return new ResponseEntity<>(esLogService.getLabelsValues(type), HttpStatus.OK); return new ResponseEntity<>(esLogService.getLabelsValues(type), HttpStatus.OK);
} }
@PostMapping("/query") @PostMapping("/query")
public ResponseEntity<Object> queryAll(@RequestBody LogQuery query) { public ResponseEntity<Object> queryAll(@RequestBody LogQuery query) {
return new ResponseEntity<>(esLogService.query(query), HttpStatus.OK); return new ResponseEntity<>(esLogService.query(query), HttpStatus.OK);
} }
@DeleteMapping("/clearLogs") @DeleteMapping("/clearLogs")
public ResponseEntity<Object> clearLogs(@RequestBody LogQuery query) { public ResponseEntity<Object> clearLogs(@RequestBody LogQuery query) {
esLogService.clearLogs(query); esLogService.clearLogs(query);
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);

View File

@@ -16,6 +16,7 @@ import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.*; import org.apache.lucene.search.*;
import org.apache.lucene.store.FSDirectory; import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRef;
import org.nl.common.utils.ApiDocScan;
import org.nl.config.lucene.LuceneAppender; import org.nl.config.lucene.LuceneAppender;
import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.logging.service.EsLogService; import org.nl.modules.logging.service.EsLogService;
@@ -24,13 +25,11 @@ import org.nl.modules.logging.service.dto.LogRepositoryDTO;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.wltea.analyzer.lucene.IKAnalyzer; import org.wltea.analyzer.lucene.IKAnalyzer;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.util.*;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/** /**
* @author ldjun * @author ldjun
@@ -70,11 +69,27 @@ public class LuceneLogServiceImpl implements EsLogService {
@Override @Override
public JSONArray getLabelsValues(String type) { public JSONArray getLabelsValues(String type) {
JSONArray result = new JSONArray(); JSONArray result = new JSONArray();
for (String v : INFO_LEVEL) { switch (type){
JSONObject item = new JSONObject(); case "logLevel":
item.put("label", v); for (String v : INFO_LEVEL) {
item.put("value", v); JSONObject item = new JSONObject();
result.add(item); item.put("label", v);
item.put("value", v);
result.add(item);
}
break;
case "interface":
if (!CollectionUtils.isEmpty(ApiDocScan.Log_Url)){
Set<String> strings = ApiDocScan.Log_Url.keySet();
for (String label : strings) {
String value = ApiDocScan.Log_Url.get(label);
JSONObject item = new JSONObject();
item.put("label", label);
item.put("value", value);
result.add(item);
}
}
break;
} }
return result; return result;
} }

View File

@@ -29,7 +29,6 @@ public class AcsUtil {
return jsonObject; return jsonObject;
} }
@InterfaceLog
public JSONObject notifyAcs3(String api, JSONArray list) { public JSONObject notifyAcs3(String api, JSONArray list) {
log.info("下发ACS参数----------------------------------------+" + api + ",---" + list.toString()); log.info("下发ACS参数----------------------------------------+" + api + ",---" + list.toString());
//判断是否连接ACS系统 //判断是否连接ACS系统

View File

@@ -1,9 +1,9 @@
window.g = { window.g = {
dev: { dev: {
VUE_APP_BASE_API: 'http://localhost:8020' VUE_APP_BASE_API: 'http://localhost:8013'
}, },
prod: { prod: {
VUE_APP_BASE_API: 'http://localhost:8020' VUE_APP_BASE_API: 'http://localhost:8013'
} }

View File

@@ -7,7 +7,7 @@
<el-select <el-select
v-model="system" v-model="system"
clearable clearable
style="width: 100px; height: 35px;top: -5px;" style="width: 100px; height: 35px;top: 0px;"
placeholder="所属标签" placeholder="所属标签"
> >
<el-option <el-option
@@ -22,7 +22,7 @@
<el-select <el-select
v-model="logLevelValue" v-model="logLevelValue"
clearable clearable
style="width: 100px; height: 35px;top: -5px;" style="width: 10px; height: 35px;top: 0px;"
placeholder="日志级别" placeholder="日志级别"
> >
<el-option <el-option
@@ -34,11 +34,26 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="接口"> <el-form-item label="接口">
<el-select
v-model="requestMethod"
clearable
filterable
style="width: 150px; height: 35px;top: 0px;"
placeholder="接口"
>
<el-option
v-for="item in interfaces"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item >
<el-input <el-input
v-model="requestMethod" v-model="requestMethod"
size="mini" size="mini"
placeholder="请输入内容" placeholder="接口地址"
clearable
/> />
</el-form-item> </el-form-item>
<el-form-item label="关键字"> <el-form-item label="关键字">
@@ -200,6 +215,7 @@ export default {
return { return {
labelsOptions: [], // 所有标签和对应所有值数据 labelsOptions: [], // 所有标签和对应所有值数据
systemOptions: [], // 所有标签和对应所有值数据 systemOptions: [], // 所有标签和对应所有值数据
interfaces: [], // 所有标签和对应所有值数据
logLevelValue: '', logLevelValue: '',
system: '', system: '',
timeRange: [], timeRange: [],
@@ -274,7 +290,7 @@ export default {
}, },
created() { created() {
this.initLabelsValues('logLevel') this.initLabelsValues('logLevel')
this.initLabelsValues('system') this.initLabelsValues('interface')
}, },
methods: { methods: {
fontType(level) { fontType(level) {
@@ -294,8 +310,8 @@ export default {
if (type === 'logLevel') { if (type === 'logLevel') {
this.labelsOptions = res this.labelsOptions = res
} }
if (type === 'system') { if (type === 'interface') {
this.systemOptions = res this.interfaces = res
} }
}) })
}, },

View File

@@ -7,7 +7,7 @@ function resolve(dir) {
} }
const name = defaultSettings.title // 网址标题 const name = defaultSettings.title // 网址标题
const port = 8013 // 端口配置 const port = 8081 // 端口配置
// All configuration item explanations can be find in https://cli.vuejs.org/config/ // All configuration item explanations can be find in https://cli.vuejs.org/config/
module.exports = { module.exports = {