File tree Expand file tree Collapse file tree 2 files changed +6
-7
lines changed
src/main/java/com/logmate/streaming Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change 11package com .logmate .streaming .controller ;
22
3+ import com .logmate .streaming .common .log .LogType ;
34import com .logmate .streaming .search .OpenSearchLogSearchService ;
45import java .time .Instant ;
5- import java .time .LocalDateTime ;
6- import java .time .ZoneOffset ;
76import java .time .temporal .ChronoUnit ;
87import lombok .RequiredArgsConstructor ;
9- import org .springframework .cglib .core .Local ;
108import org .springframework .format .annotation .DateTimeFormat ;
119import org .springframework .http .ResponseEntity ;
1210import 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 ,
Original file line number Diff line number Diff line change 22
33import com .fasterxml .jackson .databind .JsonNode ;
44import com .logmate .streaming .common .constant .opensearch .OpenSearchConstant ;
5+ import com .logmate .streaming .common .log .LogType ;
56import java .time .Instant ;
67import java .util .List ;
78import 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 ))
You can’t perform that action at this time.
0 commit comments