LogEntryRepository.java 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.demo.seecanalysisbackend.repository;
  2. import com.demo.seecanalysisbackend.model.LogEntry;
  3. import org.springframework.data.domain.Page;
  4. import org.springframework.data.domain.Pageable;
  5. import org.springframework.data.elasticsearch.annotations.Query;
  6. import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
  7. import org.springframework.stereotype.Repository;
  8. import java.time.LocalDateTime;
  9. import java.util.List;
  10. @Repository
  11. public interface LogEntryRepository extends ElasticsearchRepository<LogEntry, String> {
  12. Page<LogEntry> findByTimestampBetween(LocalDateTime startTime, LocalDateTime endTime, Pageable pageable);
  13. Page<LogEntry> findByTimestampBetweenAndLevelIn(LocalDateTime startTime, LocalDateTime endTime,
  14. List<String> levels, Pageable pageable);
  15. Page<LogEntry> findByTimestampBetweenAndApplicationIn(LocalDateTime startTime, LocalDateTime endTime,
  16. List<String> applications, Pageable pageable);
  17. List<LogEntry> findByTimestampBetweenAndLevel(LocalDateTime startTime, LocalDateTime endTime, String level);
  18. Page<LogEntry> findByTimestampBetweenAndBizName(LocalDateTime startTime, LocalDateTime endTime,
  19. String bizName, Pageable pageable);
  20. Page<LogEntry> findByTimestampBetweenAndBizNameIn(LocalDateTime startTime, LocalDateTime endTime,
  21. List<String> bizNames, Pageable pageable);
  22. @Query("{\"bool\": {\"must\": [{\"range\": {\"@timestamp\": {\"gte\": \"?0\", \"lte\": \"?1\"}}}, {\"multi_match\": {\"query\": \"?2\", \"fields\": [\"raw_message\", \"business_info\", \"method_location\", \"service_name\", \"trace_id\", \"bizName\"]}}]}}")
  23. Page<LogEntry> findByTimestampBetweenAndMessage(LocalDateTime startTime, LocalDateTime endTime,
  24. String message, Pageable pageable);
  25. @Query("{\"bool\": {\"must\": [{\"range\": {\"@timestamp\": {\"gte\": \"?0\", \"lte\": \"?1\"}}}, {\"term\": {\"log_level\": \"?2\"}}]}}")
  26. long countByTimestampBetweenAndLevel(LocalDateTime startTime, LocalDateTime endTime, String level);
  27. @Query("{\"bool\": {\"must\": [{\"range\": {\"@timestamp\": {\"gte\": \"?0\", \"lte\": \"?1\"}}}]}}")
  28. long countByTimestampBetween(LocalDateTime startTime, LocalDateTime endTime);
  29. @Query("{\"bool\": {\"must\": [{\"range\": {\"@timestamp\": {\"gte\": \"?0\", \"lte\": \"?1\"}}}, {\"term\": {\"bizName\": \"?2\"}}]}}")
  30. long countByTimestampBetweenAndBizName(LocalDateTime startTime, LocalDateTime endTime, String bizName);
  31. @Query("{\"bool\": {\"must\": [{\"range\": {\"@timestamp\": {\"gte\": \"?0\", \"lte\": \"?1\"}}}, {\"term\": {\"service_name\": \"?2\"}}]}}")
  32. Page<LogEntry> findByTimestampBetweenAndServiceName(LocalDateTime startTime, LocalDateTime endTime,
  33. String serviceName, Pageable pageable);
  34. @Query("{\"bool\": {\"must\": [{\"range\": {\"@timestamp\": {\"gte\": \"?0\", \"lte\": \"?1\"}}}, {\"term\": {\"trace_id\": \"?2\"}}]}}")
  35. Page<LogEntry> findByTimestampBetweenAndTraceId(LocalDateTime startTime, LocalDateTime endTime,
  36. String traceId, Pageable pageable);
  37. }