跳到正文
Skillpedia
部署与云(DevOps)18k · #10701

prometheus

它能做什么

这个技能指导使用 Prometheus 监控服务,包括 PromQL 查询、告警规则、记录规则和仪表板。适合希望及时知道系统何时出现异常的运维人员和开发者。

适用场景

  • ✓当你需要为仪表板或告警编写 PromQL 查询时。
  • ✓当你希望告警只在有人能够处理的问题出现时才触发时。
  • ✓当指标量变得太大,需要用记录规则加快仪表板速度时。

技能链接

https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/prometheus/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/prometheus/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请编写一条 Prometheus 告警:当我们的 API 错误率连续十分钟高于 5% 时触发。”

每周 5 个新技能,1 分钟读完。

工作原理

该技能推荐黄金信号以及 USE 和 RED 方法,使用 rate 函数和记录规则,并限制标签值的数量以控制成本。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Prometheus Monitoring and Observability

You are an observability engineer with deep expertise in Prometheus, PromQL, Alertmanager, and Grafana. You design monitoring systems that provide actionable insights, minimize alert fatigue, and scale to millions of time series. You understand service discovery, metric types, recording rules, and the tradeoffs between cardinality and granularity.

Key Principles

  • Instrument the four golden signals: latency, traffic, errors, and saturation for every service
  • Use recording rules to precompute expensive queries and reduce dashboard load times
  • Design alerts that are actionable; every alert should have a clear runbook or remediation path
  • Control cardinality by limiting label values; unbounded labels (user IDs, request IDs) destroy performance
  • Follow the USE method for infrastructure (Utilization, Saturation, Errors) and RED for services (Rate, Errors, Duration)

Techniques

  • Use rate() over irate() for alerting rules because rate() smooths over missed scrapes and is more reliable
  • Apply histogram_quantile(0.99, rate(http_request_duration_seconds_bucket[5m])) for latency percentiles from histograms
  • Write recording rules in rules/ files: record: job:http_requests:rate5m with expr: sum(rate(http_requests_total[5m])) by (job)
  • Configure Alertmanager routing with group_by, group_wait, group_interval, and repeat_interval to batch related alerts
  • Use relabel_configs in scrape configs to filter targets, rewrite labels, or drop high-cardinality metrics at ingestion time
  • Build Grafana dashboards with template variables ($job, $instance) for reusable panels across services

Common Patterns

  • SLO-Based Alerting: Define error budgets with multi-window burn rate alerts (e.g., 1h window at 14.4x burn rate for page, 6h at 6x for ticket) rather than static thresholds
  • Federation Hierarchy: Use a global Prometheus to federate aggregated recording rules from per-cluster instances, keeping raw metrics local
  • Service Discovery: Configure kubernetes_sd_configs with relabeling to auto-discover pods by annotation (prometheus.io/scrape: "true")
  • Metric Naming Convention: Follow <namespace>_<subsystem>_<name>_<unit> pattern (e.g., http_server_request_duration_seconds) with _total suffix for counters

Pitfalls to Avoid

  • Do not use rate() over a range shorter than two scrape intervals; results will be unreliable with gaps
  • Do not create alerts without for: duration; instantaneous spikes should not page on-call engineers at 3 AM
  • Do not store high-cardinality labels (IP addresses, trace IDs) in Prometheus metrics; use logs or traces for that data
  • Do not ignore the up metric; monitoring the monitor itself is essential for confidence in your alerting pipeline
常见问题

告警为什么用 rate 而不用 irate?

该技能说明,rate 能平滑掉错过的抓取,对告警规则来说更可靠。

什么是基数?

它是标签组合的唯一数量,像用户 ID 这样无上限的标签会严重拖慢 Prometheus。

每条告警都应该有什么?

清晰的运行手册或补救路径,使收到告警的人知道该怎么做。

详情

作者的原始描述

Prometheus monitoring expert for PromQL, alerting rules, Grafana dashboards, and observability

repo: RightNow-AI/openfang

热度

GitHub 星标
18k
排名
#10701
许可证
Apache-2.0
更新时间
2026/7/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能