feat(rules): Prometheus 형식 룰 파일 리더 - #11
Merged
Merged
Conversation
Go 표준 라이브러리에 YAML 파서가 없고 이 제품은 외부 의존성을 두지 않으므로 직접 읽는다. 다만 일반 YAML 파서는 만들지 않는다 — 스키마가 고정돼 있으므로 그것만 아는 리더가 훨씬 작고, 지원하지 않는 문법을 조용히 삼킬 위험도 없다. 앵커·멀티라인 블록은 룰 파일에 쓰이지 않으므로 만나면 에러를 낸다. - 파일 하나라도 잘못되면 전체가 실패한다. 절반만 로드되면 어떤 알림이 살아 있는지 아무도 모른다. - record 룰은 이름을 밝히며 거절한다(알림 룰만 받는다). - 주석은 따옴표 **밖**의 # 부터 지운다 — 안까지 지우면 summary: "번호 #42" 가 잘린다. - 값의 콜론은 그대로 둔다. PromQL 식에는 콜론이 흔하다. - 로드 순서를 파일시스템에 맡기지 않고 이름순으로 고정한다.
|
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.
룰을 파일로 정의할 수 있게 합니다. 스펙에서 놓쳤던 문제를 여기서 해결합니다.
문제
Prometheus rule 파일은 YAML 인데 Go 표준 라이브러리에 YAML 파서가 없고, 이 제품은 외부 의존성을 두지 않으므로 가져올 수도 없습니다.
일반 YAML 파서를 만들지 않은 이유
스키마가 고정돼 있습니다(
groups > rules > alert/expr/for/labels/annotations). 그것만 아는 리더가 훨씬 작고, 지원하지 않는 문법을 조용히 삼킬 위험도 없습니다 — 앵커나 멀티라인 블록을 만나면 에러를 냅니다. 반쯤 동작하는 범용 파서가 가장 위험합니다.조용히 틀리는 지점
주석은 따옴표 밖의
#부터만 지웁니다. 안까지 지우면summary: "번호 #42"가 잘립니다.값의 콜론은 그대로 둡니다 — PromQL 식에는 콜론이 흔합니다(
job:x:sum, 라벨 매처).파일 하나라도 잘못되면 전체 실패. 절반만 로드되면 어떤 알림이 살아 있는지 아무도 모릅니다.
로드 순서를 파일시스템에 맡기지 않습니다 — 이름순으로 고정합니다.
그 외
record룰은 이름을 밝히며 거절 (알림 룰만 받음).yaml/.yml만 읽고 나머지는 무시검증
6개 테스트: 그룹·룰·labels·annotations 파싱 / 잘못된 식 거절 / record 거절 / 주석·빈 줄 / 따옴표 안의 # / 비-YAML 무시.