feat(rules): 알림 룰 평가와 상태머신 - #9
Merged
Merged
Conversation
상태가 이 패키지의 존재 이유다 — 조건이 참인지는 promql 이 답하지만 '언제부터 참이었나'·'이미 알린 것인가' 는 평가 사이에 기억해야 안다. - inactive → pending → firing. for 가 0 이면 pending 을 건너뛴다. - 조건이 한 번 풀리면 ActiveAt 을 다시 찍는다. 이어서 세면 짧은 깜빡임이 쌓여 firing 이 되고, 순간 스파이크가 전부 알림이 된다. - 조건이 풀린 알림은 상태에서 지운다. 남기면 해소된 알림이 계속 울린다. - **평가 실패는 '조건이 거짓' 과 다르게 다룬다.** 기존 상태를 그대로 두어 일시적 실패가 알림을 해소시키지 않게 한다. - 라벨셋마다 독립된 알림이고, 룰 라벨이 결과 라벨을 덮는다(severity 는 룰이 정한다). - 식은 룰을 만들 때 파싱한다 — 평가마다 실패하는 룰을 안고 도는 것보다 낫다.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
알림 스펙(1a)의 룰 엔진입니다.
promql+storage위에 얹혀 조건을 주기적으로 평가하고 상태를 관리합니다.상태가 이 패키지의 존재 이유
조건이 참인지는 promql 이 답합니다. 하지만 "언제부터 참이었나" 와 "이미 알린 것인가" 는 평가 사이에 기억해야 알 수 있고, 그게 여기입니다.
inactive → pending → firing, 해소 시 상태에서 제거.값이 조용히 틀리는 지점
for재시작. 조건이 한 번 풀리면ActiveAt을 다시 찍습니다. 이어서 세면 짧은 깜빡임이 쌓여 firing 이 되어, 순간 스파이크가 전부 알림이 됩니다.해소 처리. 조건을 만족하지 않게 된 알림은 내부 상태에서 지웁니다. 남기면 해소된 알림이 계속 울립니다.
평가 실패 ≠ 조건 거짓. 질의가 실패하면 기존 상태를 그대로 둡니다. 실패를 "거짓"으로 취급하면 저장소가 잠깐 삐끗한 것만으로 firing 중인 알림이 해소돼 버립니다.
그 외
severity는 룰이 정하는 값alertname자동 부착검증
7개 테스트:
for=0 즉시 firing /for경계 전후 / 해소 / 깜빡임 후 재시작 / 라벨셋별 추적 / 룰 라벨 부착 / 잘못된 식 거절. 실제 tsdb + promql 을 통해 평가합니다.다음
발송기(
internal/notify)와 룰 파일 파서. 후자는 스펙에서 놓친 문제가 있습니다 — Prometheus rule 파일은 YAML 인데 Go 표준 라이브러리에 파서가 없고, 의존성 0 이라 가져올 수도 없습니다. YAML 서브셋 파서를 직접 만들어야 합니다.