设置 Prometheus 以实现全面的指标收集、告警和基础设施监控。此技能提供完整的配置指南,包括抓取目标、记录规则和告警定义。
下载技能 ZIP
在 Claude 中上传
前往 设置 → 功能 → 技能 → 上传技能
开启并开始使用
测试它
正在使用“prometheus-configuration”。 为我的 Kubernetes 集群设置 Prometheus 监控
预期结果:
- ## Kubernetes Prometheus 安装 ### 使用 Helm 安装 ```bash helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm install prometheus prometheus-community/kube-prometheus-stack --namespace monitoring --create-namespace ``` ### 基础抓取配置 ```yaml scrape_configs: - job_name: 'kubernetes-nodes' kubernetes_sd_configs: - role: node ```
正在使用“prometheus-configuration”。 为 API 指标创建记录规则
预期结果:
- ## API 记录规则 ```yaml groups: - name: api_metrics rules: - record: job:http_requests:rate5m expr: sum by (job) (rate(http_requests_total[5m])) - record: job:http_requests_error_rate:percentage expr: |- (sum by (job) (rate(http_requests_total{status=~"5.."}[5m])) / job:http_requests:rate5m) * 100 ```
正在使用“prometheus-configuration”。 配置高 CPU 告警
预期结果:
- ## 告警规则:高 CPU 使用率 ```yaml - alert: HighCPUUsage expr: instance:node_cpu:utilization > 80 for: 5m labels: severity: warning annotations: summary: "High CPU usage on {{ $labels.instance }}" description: "CPU usage is {{ $value }}%" ```
安全审计
安全This is a legitimate Prometheus configuration documentation skill. The static scanner flagged code examples within markdown documentation as executable code, which is a false positive. All detected patterns (external commands, network URLs, certificate paths, crypto algorithms) appear in YAML/bash code blocks showing configuration examples - not actual runtime code. No malicious intent detected. Skill is safe for publication.
严重问题 (1)
中风险问题 (4)
质量评分
你能构建什么
DevOps 工程师设置监控
为新的基础设施项目从头配置 Prometheus,包含适当的抓取目标和告警
SRE 团队定义告警规则
为服务可用性、错误率和资源利用率创建全面的告警规则
开发人员为应用程序添加检测
学习 Prometheus 指标命名规范和应用程序端点的抓取配置
试试这些提示
为我的 Kubernetes 集群设置 Prometheus 监控。包含节点导出器的基本抓取配置和服务可用性的基本告警。
为常见 API 指标创建记录规则,包括请求率、错误率百分比和 P95 延迟。展示如何按服务组织它们。
设计高 CPU 使用率(阈值 80%,持续 5 分钟)、高内存使用率(阈值 85%)和磁盘空间不足(阈值 90%)的告警规则。包含适当的标签和注释。
配置 Prometheus 使用注解自动发现 Kubernetes 中的服务。展示重标记规则以添加环境和区域标签。
最佳实践
- 使用一致的指标命名格式,例如前缀_单位格式(如 http_requests_total)
- 设置适当的抓取间隔(通常 15-60 秒,关键指标 5 秒)
- 为频繁查询的昂贵表达式创建记录规则
避免
- 避免过于频繁地抓取(高资源使用)
- 不要在没有持续时间的情况下对瞬时峰值告警
- 避免创建重复原始指标的记录规则