Interface AlertEventRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<AlertEventEntity,,Long> org.springframework.data.jpa.repository.JpaRepository<AlertEventEntity,,Long> org.springframework.data.repository.ListCrudRepository<AlertEventEntity,,Long> org.springframework.data.repository.ListPagingAndSortingRepository<AlertEventEntity,,Long> org.springframework.data.repository.PagingAndSortingRepository<AlertEventEntity,,Long> org.springframework.data.repository.query.QueryByExampleExecutor<AlertEventEntity>,org.springframework.data.repository.Repository<AlertEventEntity,Long>
@Repository
public interface AlertEventRepository
extends org.springframework.data.jpa.repository.JpaRepository<AlertEventEntity,Long>
Spring Data JPA repository for
AlertEventEntity.
Supports paginated retrieval of alert events by service for the alert log UI, bulk deletion by age for the data-retention service, and fetching the N most recent events across all services for the dashboard.
- Author:
- Nazar Montytskyi
-
Method Summary
Modifier and TypeMethodDescriptionintdeleteByFiredAtBefore(LocalDateTime threshold) booleanexistsByRuleIdAndFiredAtAfter(Long ruleId, LocalDateTime since) org.springframework.data.domain.Page<AlertEventEntity> findAllByFiredAtBetweenOrderByFiredAtDesc(LocalDateTime from, LocalDateTime to, org.springframework.data.domain.Pageable pageable) Returns a paginated list of all alert events within a time range, newest first.org.springframework.data.domain.Page<AlertEventEntity> findAllByServiceIdAndFiredAtBetweenOrderByFiredAtDesc(Long serviceId, LocalDateTime from, LocalDateTime to, org.springframework.data.domain.Pageable pageable) org.springframework.data.domain.Page<AlertEventEntity> findAllByServiceIdOrderByFiredAtDesc(Long serviceId, org.springframework.data.domain.Pageable pageable) Returns a paginated list of all alert events for a service, newest first.Finds the most recent event fired for a specific alert rule.Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, saveMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAllMethods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Method Details
-
findAllByServiceIdOrderByFiredAtDesc
org.springframework.data.domain.Page<AlertEventEntity> findAllByServiceIdOrderByFiredAtDesc(Long serviceId, org.springframework.data.domain.Pageable pageable) Returns a paginated list of all alert events for a service, newest first. Used by the event log page andGET /api/alerts/events?serviceId=.- Parameters:
serviceId- the service identifierpageable- pagination and sorting parameters- Returns:
- page of alert events
-
findAllByFiredAtBetweenOrderByFiredAtDesc
org.springframework.data.domain.Page<AlertEventEntity> findAllByFiredAtBetweenOrderByFiredAtDesc(LocalDateTime from, LocalDateTime to, org.springframework.data.domain.Pageable pageable) Returns a paginated list of all alert events within a time range, newest first. Used by the REST API to support time-filtered queries.- Parameters:
from- start of the time window (inclusive)to- end of the time window (inclusive)pageable- pagination and sorting parameters- Returns:
- page of alert events
-
findAllByServiceIdAndFiredAtBetweenOrderByFiredAtDesc
org.springframework.data.domain.Page<AlertEventEntity> findAllByServiceIdAndFiredAtBetweenOrderByFiredAtDesc(Long serviceId, LocalDateTime from, LocalDateTime to, org.springframework.data.domain.Pageable pageable) -
findTopByRuleIdOrderByFiredAtDesc
Finds the most recent event fired for a specific alert rule. Used byAlertCooldownManagerto determine whether the cooldown period has elapsed before firing another notification.- Parameters:
ruleId- the alert rule identifier- Returns:
- the most recent event for this rule, if any
-
existsByRuleIdAndFiredAtAfter
@Query("SELECT COUNT(e) > 0 FROM AlertEventEntity e WHERE e.rule.id = :ruleId AND e.firedAt >= :since") boolean existsByRuleIdAndFiredAtAfter(@Param("ruleId") Long ruleId, @Param("since") LocalDateTime since) -
deleteByFiredAtBefore
@Modifying @Query("DELETE FROM AlertEventEntity a WHERE a.firedAt < :threshold") int deleteByFiredAtBefore(@Param("threshold") LocalDateTime threshold)
-