用途:配置 Prometheus,实现基础设施与应用的指标采集、告警和监控,适用于搭建监控、配置指标抓取、创建记录规则、设计告警规则、实现服务发现等任务。与 Prometheus 配置无关的任务不适用。
主要能力:涵盖 Prometheus 架构(应用通过 /metrics 暴露指标,服务端周期抓取,可对接 AlertManager、Grafana 与长期存储 Thanos/Cortex);提供 Kubernetes Helm 与 Docker Compose 两种安装方式;给出 prometheus.yml 全局设置、alerting、rule_files 与 scrape_configs 配置;支持静态目标、基于文件的服务发现与 Kubernetes 服务发现;附带记录规则(请求速率、错误率、P95 延迟、节点 CPU/内存/磁盘利用率)和告警规则(服务宕机、高错误率、高延迟、高 CPU/内存、磁盘不足)示例。
使用方式:Kubernetes 下用 helm repo add prometheus-community https://prometheus-community.github.io/helm-charts 并安装 kube-prometheus-stack;Docker Compose 挂载 prometheus.yml 运行;用 promtool check config、promtool check rules 及 promtool query 校验配置与规则;通过 curl http://localhost:9090/api/v1/targets 等接口排障。
限制:本目录未内置 assets/prometheus.yml.template、references/scrape-configs.md、references/recording-rules.md、scripts/validate-prometheus.sh 等外部支撑文件,需自行获取原始材料并确认许可与执行前提,缺失前不得运行依赖步骤。使用前应明确目标、约束与输入;输出不能替代针对具体环境的验证、测试或专家评审;缺少输入、权限、安全边界或成功标准时应先询问。相关技能:grafana-dashboards、slo-implementation、distributed-tracing。