协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
alerting【开发与工程】Use this skill when the user asks about alert rules, Alertmanager, Prometheus alerts, Grafana alerts, notification routing, PagerDuty, on-call, escalation, alert fatigue, or threshold tuning.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Design alert rules following the RED/USE method with severity classification, threshold tuning, notification routing, and escalation paths. Ensure every alert is actionable, documented with a runbook, and tuned to balance detection speed against fatigue.
Four principles guide alert rule design:
Rate, Errors, Duration — the three golden signals for application monitoring.
Rate: How much traffic is flowing through the system?
Query: rate(http_requests_total[5m])
Alert: sudden drop (possible outage) or unexpected surge (traffic anomaly)
Errors: What fraction of requests are failing?
Query: rate(http_requests_total{status=~"5.."}[5m]) / rate(http_requests_total[5m])
Alert: > 1% warning, > 5% critical
Duration: How long do requests take?
Query: histogram_quantile(0.99, rate(http_request_duration_seconds_bucket[5m]))
Alert: p99 > 500ms warning, > 2s critical
Utilization, Saturation, Errors — resource-focused monitoring.
Utilization: What percentage of capacity is being used?
CPU: node_cpu_seconds_total{mode="idle"} < 0.1
Memory: node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes < 0.1
Disk: node_filesystem_avail_bytes / node_filesystem_size_bytes < 0.1
Saturation: How much extra work is queued?
CPU run queue length > 4 * core count
Disk I/O queue depth > disk I/O capacity
Network interface drops > 0
Errors: How many errors are occurring?
OOM kills: increase(node_vmstat_oom_kill[5m]) > 0
Disk errors: increase(node_disk_io_time_seconds_total[5m]) > 0
Network errors: increase(node_network_transmit_errors_total[5m]) > 0
Domain-specific alerts on revenue-impacting signals.
- Order failure rate > 10%
- Payment processing delay > 30s p95
- User signup completion rate < 90%
- API integration partner error rate > 5%
- Cart abandonment rate spike > 20% above baseline
Alert Fatigue Risk = (Total Alerts / Week) / (Actionable Alerts / Week)
Healthy: < 3 alerts per actionable alert
Warning: 3-10 alerts per actionable (investigate thresholds)
Critical: > 10 alerts per actionable (urgent tuning needed)
Target: < 5 total alerts per on-call person per shift
Maximum: 10 alerts per shift before burnout risk
Will someone take immediate action when this fires?
├── Yes → What action?
│ ├── Rollback, restart, failover
│ │ └── P0/P1 alert with runbook
│ ├── Investigate during business hours
│ │ └── P2 alert with runbook
│ └── Investigate when someone has time
│ └── P3 alert or ticket, not pager
└── No → Is it useful for post-mortem analysis?
├── Yes → Dashboard panel + log
└── No → Delete the metric or reduce collection frequency
User request includes: alert rule, alertmanager, prometheus alert, grafana alert, notification, pagerduty, on-call, escalation, alert fatigue, threshold.
A markdown document containing:
Produce the artifact directly. No preamble. No postamble. No explanations.
4096 tokens
Map severity (P0-P3) to response SLA, notification channels, and escalation paths.
P0: Critical -- 5 min acknowledge, 1 hr fix -- Phone + Slack + PagerDuty
Escalation: EM -> CTO -- Example: total service outage, data loss
P1: High -- 15 min acknowledge, 4 hr fix -- Slack + PagerDuty
Escalation: Team lead -- Example: high error rate, degraded performance
P2: Warning -- 1 hr acknowledge, 24 hr fix -- Slack
Escalation: None -- Example: disk usage rising, latency increasing
P3: Info -- Next business day -- Dashboard only
Escalation: None -- Example: certificate expiring in 30 days
Define rate, error, and duration alerts for application services.
HighErrorRate: rate(5xx) / rate(total) > 0.05 for 5m -> P1
HighLatency: p99 latency > 2s for 5m -> P1
ZeroTraffic: rate(requests) == 0 for 5m -> P0
HighTrafficSurge: rate(requests) > 3x baseline for 10m -> P2
Define utilization, saturation, and error alerts for infrastructure resources.
HighCpuUsage: idle < 10% for 10m -> P2
DiskSpaceRunningOut: avail < 10% for 5m -> P2
HighMemoryUsage: avail < 10% for 5m -> P2
OOMKillDetected: oom_kill > 0 -> P1
DiskIOLatency: avg_queue_latency > 100ms for 10m -> P2
NetworkPacketLoss: tx_errors > 5% for 5m -> P2
Create domain-specific alerts for order failures, payment delays, and other business metrics.
OrderFailureRate: failure rate > 10% for 10m -> P1
PaymentProcessingDelay: p95 > 30s for 5m -> P1
SignupCompletionDrop: completion rate < 90% for 15m -> P2
Apply threshold tuning rules to balance detection speed against alert fatigue.
- Start with conservative thresholds (higher tolerance).
- Review monthly: are alerts firing? Are they actionable?
- Adjust based on: false positive rate, detection latency, business impact.
- Use seasonal baselines: peak vs off-peak thresholds.
- Implement dynamic thresholds for predictable traffic patterns.
Map severity to notification channels with escalation matrix.
P0 -> Phone + Slack + PagerDuty -> EM after 5 min no ack -> CTO after 15 min
P1 -> Slack + PagerDuty -> Team lead after 15 min no ack
P2 -> Slack channel -> Escalate after 1 hr if no response
P3 -> Dashboard + email digest -> No escalation
Every alert must have a documented runbook with diagnosis and resolution steps.
Runbook template per alert:
1. Symptom description
2. Possible causes (ordered by likelihood)
3. Diagnostic steps (commands to run, metrics to check)
4. Resolution steps
5. Verification procedure
6. Escalation path
Define policy for silencing alerts during planned operations.
- Pre-approved maintenance window: silence P2/P3 alerts automatically.
- Post notification in on-call channel before starting.
- Maximum window: 4 hours (extend only with manager approval).
- Auto-expire: alerts resume when window ends.
- Exception: P0 alerts never silenced during maintenance.
Track alert health metrics and implement improvements.
- Alert volume per severity per service (target: < 5 P0/month per service).
- Time-to-acknowledge per severity (target: < 5 min P0).
- False positive rate (target: < 20%).
- MTTA (mean time to acknowledge) per team.
- MTTR (mean time to resolve) per alert type.
Design sustainable on-call rotations to prevent burnout.
- Team size for on-call: minimum 4 people for weekly rotations
- Rotation length: 1 week (shorter = better, 1 day for high-volume teams)
- Secondary on-call: always have a backup
- Follow-the-sun: preferred for global teams
- Compensation: time off in lieu or on-call pay
- Handoff: scheduled 30-min overlap on rotation day
- Escalation path documented in the rotation schedule
for: durations.for: duration: Single data point flaps cause false alerts.for: duration equal to at least 2-3 scrape intervals| Approach | Strengths | Weaknesses |
|---|---|---|
| RED method (this skill) | Covers user-facing signals, simple | Misses infrastructure saturation |
| USE method (this skill) | Covers resource health | Needs RED for full picture |
| Four golden signals | Complete coverage (RED + USE) | More alerts to manage |
| Single metric alerts | Simple to implement | Misses composite conditions |
| Anomaly detection | Catches unknown unknowns | High false positive rate |
| SLO-based alerting | Business-aligned | Requires SLO definition effort |
| Log-based alerting | Deep context | High volume, slow |
| Tracing-based alerting | Precise root cause | High overhead, sampling tradeoff |
alert: {{ALERT_NAME}}
expr: {{PROMQL_EXPRESSION}}
for: {{DURATION}}
labels:
severity: {{P0|P1|P2|P3}}
team: {{TEAM_NAME}}
service: {{SERVICE_NAME}}
annotations:
summary: "{{BRIEF_DESCRIPTION}}"
description: "{{DETAILED_DESCRIPTION}}"
runbook: "https://runbooks.team.com/{{ALERT_NAME}}"
route:
receiver: "default"
routes:
- match: {severity: "P0"}
receiver: "pagerduty-critical"
repeat_interval: 5m
- match: {severity: "P1"}
receiver: "pagerduty-high"
repeat_interval: 30m
- match: {severity: "P2"}
receiver: "slack-warnings"
repeat_interval: 4h
receivers:
- name: "pagerduty-critical"
pagerduty_configs:
- routing_key: "{{PAGERDUTY_KEY}}"
severity: "critical"
- name: "slack-warnings"
slack_configs:
- channel: "#alerts"
title: "{{ .GroupLabels.alertname }}"
Metric | Current | Target | Status
Total alerts/week | 42 | < 25 | Needs tuning
P0 alerts/month | 3 | < 5 | Healthy
False positive rate | 28% | < 20% | Review thresholds
MTTA P0 | 3 min | < 5 min| Healthy
MTTR P0 | 25 min | < 60 min| Healthy
Alerts per on-call | 6/shift | < 5 | Near limit
Team: {name} | Week: {date} - {date}
Primary: {name} (acknowledge within 5 min)
Secondary: {name} (backup if primary unresponsive)
Handoff scheduled: Monday 09:00 (30 min overlap)
Escalation path:
Primary unresponsive > 5 min → Secondary
Secondary unresponsive > 5 min → Engineering Manager
EM unresponsive > 5 min → CTO
for: duration before firing to prevent flappingHand off to devops/monitoring/SKILL.md for monitoring stack setup.
Hand off to management/team-rules/SKILL.md for on-call schedule and incident response.
| Decision Point | Option A | Option B | Decision Criteria |
|---|---|---|---|
| Alert channel | Email (archival) | PagerDuty/Opsgenie (real-time) | Urgency, response SLA |
| Notification platform | Built-in (Grafana) | Dedicated (PagerDuty) | Cost vs flexibility, existing stack |
| Escalation strategy | Linear escalation | Tiered/broadcast escalation | Team size, criticality tiers |
`yaml groups:
yaml escalation_policy: name: "Backend On-Call" rules: - targets: [primary_on_call] timeout: 15m - targets: [secondary_on_call] timeout: 10m - targets: [engineering_manager] timeout: 5m - targets: [incident_command] notify: immediate
| Anti-Pattern | Symptom | Solution |
|---|---|---|
| Alerting everything | 500+ alerts/day, all ignored | Alert on symptoms, not causes. Start with < 10 rules |
| No runbook | On-call wakes up and doesn't know what to do | Every alert must link to a runbook |
| Friday evening deploys | Weekend pages | Restrict deploys to business hours |
| Silent threshold increase | Decreased sensitivity masks real issues | Track MTTA/MTTR alongside alert volume |
| No alert testing | False sense of security | Weekly alert simulation drills |
Alert data leakage: Sanitize alert payloads to exclude secrets. Mask sensitive values in alert annotations.
Secure runbooks: Host runbooks in authenticated internal wikis. Never embed API keys or passwords in runbook steps.
Post-incident review: Conduct blameless postmortems. Preserve alert data and timelines for forensic analysis.
Audit trail maintenance: Retain alert and incident records per compliance requirements. Archive resolved incidents for trend analysis.
On-call shift logging: Log all on-call actions, escalations, and handoffs. Use time-stamped entries for postmortem reconstruction.
Notification delivery confirmation: Verify all critical alerts are acknowledged. Escalate unacknowledged pages after timeout.
Alert volume trending: Track weekly alert volume per service. Set targets for reducing noise-to-signal ratio.
Cross-team incident coordination: Document handoff procedures between primary and secondary on-call teams. Maintain shared incident timeline.