Skip to content

Commit 509403a

Browse files
committed
[Fix] 로그타입에 대한 쿼리 버그 수정
1 parent 1fb9793 commit 509403a

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/main/java/com/logmate/streaming/controller/LogSearchController.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package com.logmate.streaming.controller;
22

3+
import com.logmate.streaming.common.log.LogType;
34
import com.logmate.streaming.search.OpenSearchLogSearchService;
45
import java.time.Instant;
5-
import java.time.LocalDateTime;
6-
import java.time.ZoneOffset;
76
import java.time.temporal.ChronoUnit;
87
import lombok.RequiredArgsConstructor;
9-
import org.springframework.cglib.core.Local;
108
import org.springframework.format.annotation.DateTimeFormat;
119
import org.springframework.http.ResponseEntity;
1210
import org.springframework.web.bind.annotation.GetMapping;
@@ -27,7 +25,7 @@ public class LogSearchController {
2725
public ResponseEntity<?> searchLogs(
2826
@RequestParam String agentId,
2927
@RequestParam Integer thNum,
30-
@RequestParam String logType,
28+
@RequestParam LogType logType,
3129
@RequestParam(required = false)
3230
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
3331
Instant startTime,

src/main/java/com/logmate/streaming/search/OpenSearchLogSearchService.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.fasterxml.jackson.databind.JsonNode;
44
import com.logmate.streaming.common.constant.opensearch.OpenSearchConstant;
5+
import com.logmate.streaming.common.log.LogType;
56
import java.time.Instant;
67
import java.util.List;
78
import lombok.RequiredArgsConstructor;
@@ -27,19 +28,19 @@ public class OpenSearchLogSearchService {
2728
*/
2829
public List<JsonNode> searchLogs(String agentId,
2930
Integer thNum,
30-
String logType,
31+
LogType logType,
3132
Instant startTime,
3233
Instant endTime) {
3334
try {
3435

3536
// 인덱스 패턴 (예: log-spring_boot-logs-*, log-tomcat_access-logs-*)
36-
String indexPattern = constant.index.LOG + "-" + logType.toLowerCase() + "-" + constant.index.LOG + "-*";
37+
String indexPattern = constant.index.LOG + "-" + logType.getStr().toLowerCase() + "-" + constant.index.LOG + "-*";
3738

3839
// 검색 조건
3940
Query query = Query.of(q -> q.bool(b -> b
4041
.must(m -> m.term(t -> t.field("agentId").value(FieldValue.of(agentId))))
4142
.must(m -> m.term(t -> t.field("thNum").value(FieldValue.of(thNum))))
42-
.must(m -> m.term(t -> t.field("logType").value(FieldValue.of(logType))))
43+
.must(m -> m.term(t -> t.field("logType").value(FieldValue.of(logType.toString()))))
4344
.must(m -> m.range(r -> r
4445
.field("log.timestamp")
4546
.gte(JsonData.of(startTime))

0 commit comments

Comments
 (0)