prometheus
Query Prometheus API for cluster metrics, alerts, and observability data. Use when investigating cluster health, performance issues, resource utilization, or alert status. Triggers on questions like "what's the CPU usage", "show me firing alerts", "check memory pressure", "query prometheus for", or any PromQL-related requests.
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
Prometheus Querying
Setup
Prometheus runs in-cluster. Establish access via port-forward:
KUBECONFIG=~/.kube/<cluster>.yaml kubectl port-forward -n monitoring svc/prometheus-operated 9090:9090
Clusters: dev, integration, live
Quick Queries
Use the bundled script at .claude/skills/prometheus/scripts/promql.sh:
# Set URL (default: localhost:9090)
export PROMETHEUS_URL=http://localhost:9090
# Instant query
./scripts/promql.sh query 'up'
# Range query (last hour, 15s resolution)
./scripts/promql.sh range 'node_cpu_seconds_total' --start 1h --step 15s
# Firing alerts only
./scripts/promql.sh alerts --firing
# All alert rules
./scripts/promql.sh rules
# Find metrics by label
./scripts/promql.sh series '{job="node-exporter"}'
# Health check
./scripts/promql.sh health
Common Operations
Check Cluster Health
# CPU usage %
./scripts/promql.sh query 'avg(1 - rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100'
# Memory usage %
./scripts/promql.sh query '(1 - sum(node_memory_MemAvailable_bytes) / sum(node_memory_MemTotal_bytes)) * 100'
# Problem pods
./scripts/promql.sh query 'kube_pod_status_phase{phase!~"Running|Succeeded"} == 1'
# Container restarts (last hour)
./scripts/promql.sh query 'increase(kube_pod_container_status_restarts_total[1h]) > 0'
Check Alerts
# All firing alerts
./scripts/promql.sh alerts --firing
# Full alert details
./scripts/promql.sh alerts --verbose
Direct curl (alternative)
# Instant query
curl -s "http://localhost:9090/api/v1/query?query=up" | jq '.data.result'
# Alerts
curl -s "http://localhost:9090/api/v1/alerts" | jq '.data.alerts'
Reference
For homelab-specific PromQL queries (Longhorn, CloudNative-PG, Cilium, etc.), see references/queries.md.
Prometheus Details
| Property | Value |
|---|---|
| Namespace | monitoring |
| Service | prometheus-operated:9090 |
| Retention | 14 days / 50GB |
| External label | prometheus_source: ${cluster_name} |
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-01-20
- 索引更新时间
- 2026-01-26
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!