feat: 支持按标签配置告警阈值覆盖#249
Open
myrat92 wants to merge 2 commits into
Open
Conversation
This was referenced Apr 27, 2026
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.
变更说明
本 PR 为 Prometheus 告警规则增加按指标标签配置阈值覆盖的能力。
在保留原有全局阈值规则的基础上,允许用户针对特定指标标签配置独立的告警条件,例如按
instance、hostname、job、os_type等标签设置不同阈值。背景
实际生产环境中,同一类节点或同一条 PromQL 告警规则下,不同节点可能需要不同阈值。
例如:
如果为每个节点复制一条告警规则,规则数量会膨胀,维护成本较高。
主要改动
severity、expr、forDuration兼容性
兼容已有规则。
如果规则中没有配置
thresholdMode或thresholdOverrides,告警评估逻辑仍使用原有全局rules,不会改变现有行为。当前覆盖规则按配置顺序匹配,第一条命中的覆盖规则生效。建议将更具体的标签匹配项放在更前面。
关联 Issue
Refs opsre/WatchAlert#ISSUE_ID