技能 prometheus-configuration
📊

prometheus-configuration

安全

配置 Prometheus 监控

也可从以下获取: wshobson

设置 Prometheus 以实现全面的指标收集、告警和基础设施监控。此技能提供完整的配置指南,包括抓取目标、记录规则和告警定义。

支持: Claude Codex Code(CC)
📊 69 充足
1

下载技能 ZIP

2

在 Claude 中上传

前往 设置 → 功能 → 技能 → 上传技能

3

开启并开始使用

测试它

正在使用“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 }}%" ```

安全审计

安全
v1 • 2/24/2026

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
已扫描文件
407
分析行数
5
发现项
1
审计总数

严重问题 (1)

False Positive: Code Execution + Network + Credential Access Heuristic
Static scanner flagged dangerous combination heuristic triggered by documentation code examples. This is a documentation skill showing Prometheus config examples in YAML and bash code blocks. No actual code execution occurs.
中风险问题 (4)
False Positive: External Commands Detection
Backtick and $() patterns appear in bash command examples within documentation. Not actual shell execution - users would run these commands themselves in their terminal.
False Positive: Network URLs Detection
Hardcoded URLs are legitimate Prometheus infrastructure: Helm chart repository and localhost for testing.
False Positive: Certificate/Key File Detection
Example TLS configuration paths in YAML documentation. Not actual sensitive files.
False Positive: Weak Cryptographic Algorithm Detection
Scanner incorrectly identifies Prometheus terminology as crypto algorithms. 'alert', 'rate', 'expr' are Prometheus config keywords, not crypto.
审计者: claude

质量评分

38
架构
100
可维护性
87
内容
50
社区
65
安全
100
规范符合性

你能构建什么

DevOps 工程师设置监控

为新的基础设施项目从头配置 Prometheus,包含适当的抓取目标和告警

SRE 团队定义告警规则

为服务可用性、错误率和资源利用率创建全面的告警规则

开发人员为应用程序添加检测

学习 Prometheus 指标命名规范和应用程序端点的抓取配置

试试这些提示

基础 Prometheus 设置
为我的 Kubernetes 集群设置 Prometheus 监控。包含节点导出器的基本抓取配置和服务可用性的基本告警。
创建记录规则
为常见 API 指标创建记录规则,包括请求率、错误率百分比和 P95 延迟。展示如何按服务组织它们。
配置告警规则
设计高 CPU 使用率(阈值 80%,持续 5 分钟)、高内存使用率(阈值 85%)和磁盘空间不足(阈值 90%)的告警规则。包含适当的标签和注释。
Kubernetes 服务发现
配置 Prometheus 使用注解自动发现 Kubernetes 中的服务。展示重标记规则以添加环境和区域标签。

最佳实践

  • 使用一致的指标命名格式,例如前缀_单位格式(如 http_requests_total)
  • 设置适当的抓取间隔(通常 15-60 秒,关键指标 5 秒)
  • 为频繁查询的昂贵表达式创建记录规则

避免

  • 避免过于频繁地抓取(高资源使用)
  • 不要在没有持续时间的情况下对瞬时峰值告警
  • 避免创建重复原始指标的记录规则

常见问题

我应该使用什么抓取间隔?
默认值为 15 秒。大多数指标使用 15-60 秒。关键实时指标使用 5-10 秒,但这会增加存储和计算需求。
如何保护 Prometheus 抓取端点?
在 prometheus.yml 中使用 TLS 配置,包括 ca_file、cert_file 和 key_file 选项。通过授权头启用基本身份验证。
记录规则和告警有什么区别?
记录规则将昂贵的查询预计算为新指标,以加快仪表板查询速度。告警在条件满足时触发通知。
如何在 Kubernetes 中发现目标?
使用 kubernetes_sd_configs,角色为 pod、service、node 或 ingress。使用 prometheus.io 注解,如 prometheus.io/scrape: 'true'。
如何验证我的配置?
使用 promtool check config prometheus.yml 和 promtool check rules rules.yml 在重新加载 Prometheus 之前验证语法。
我应该使用什么保留期?
默认值为 15 天。根据存储容量和监控需求进行调整。使用 Thanos 或 Cortex 进行超过 30 天的长期存储。

开发者详情

文件结构

📄 SKILL.md