Skill v1.0.0
currentAutomated scan100/100name: alerting-oncall description: Set up alerting rules, configure on-call rotations, and manage incident response workflows. Integrate with PagerDuty, Opsgenie, or Grafana OnCall for alert routing and escalation. Use when implementing alerting strategies and on-call management for production systems. license: MIT metadata: author: devops-skills version: "1.0"
Alerting & On-Call
Configure effective alerting and on-call management for production systems.
When to Use This Skill
Use this skill when:
- Setting up alerting rules and thresholds
- Configuring on-call rotations and schedules
- Implementing alert routing and escalation
- Reducing alert fatigue
- Managing incident response workflows
Prerequisites
- Monitoring system (Prometheus, Datadog, etc.)
- On-call platform (PagerDuty, Opsgenie, Grafana OnCall)
- Communication channels (Slack, email)
Alerting Best Practices
Alert Categories
# Severity levelscritical:- Service completely down- Data loss imminent- Security breachresponse: Immediate page, wake people uphigh:- Service degraded significantly- Error rate above SLO- Capacity near limitresponse: Page during business hours, notify after hoursmedium:- Performance degradation- Non-critical component failure- Warning thresholds exceededresponse: Notify via Slack, review next business daylow:- Informational alerts- Capacity planning triggers- Routine maintenance neededresponse: Email notification, weekly review
Alert Design Principles
# Good alert characteristicsalerts:actionable:- Every alert should require human action- Include runbook links- Clear remediation stepsrelevant:- Alert on symptoms, not causes- Focus on user impact- Avoid alerting on expected behaviortimely:- Appropriate thresholds- Suitable evaluation windows- Account for normal varianceunique:- No duplicate alerts- Proper alert grouping- Clear ownership
Prometheus Alerting
Alert Rules
# prometheus/rules/alerts.ymlgroups:- name: service_alertsrules:# High-level service health- alert: ServiceDownexpr: up{job="myapp"} == 0for: 1mlabels:severity: criticalannotations:summary: "Service {{ $labels.instance }} is down"description: "{{ $labels.job }} on {{ $labels.instance }} has been down for more than 1 minute."runbook_url: "https://wiki.example.com/runbooks/service-down"# Error rate alert- alert: HighErrorRateexpr: |sum(rate(http_requests_total{status=~"5.."}[5m])) by (service)/ sum(rate(http_requests_total[5m])) by (service) > 0.05for: 5mlabels:severity: criticalannotations:summary: "High error rate for {{ $labels.service }}"description: "Error rate is {{ $value | humanizePercentage }} for the last 5 minutes"# Latency alert (SLO-based)- alert: HighLatencyexpr: |histogram_quantile(0.95,sum(rate(http_request_duration_seconds_bucket[5m])) by (le, service)) > 0.5for: 5mlabels:severity: highannotations:summary: "P95 latency above 500ms for {{ $labels.service }}"
Alertmanager Configuration
# alertmanager.ymlglobal:resolve_timeout: 5mslack_api_url: 'https://hooks.slack.com/services/xxx'pagerduty_url: 'https://events.pagerduty.com/v2/enqueue'templates:- '/etc/alertmanager/templates/*.tmpl'route:receiver: 'default-receiver'group_by: ['alertname', 'service']group_wait: 30sgroup_interval: 5mrepeat_interval: 4hroutes:# Critical alerts go to PagerDuty- match:severity: criticalreceiver: 'pagerduty-critical'group_wait: 0srepeat_interval: 1h# High severity during business hours- match:severity: highreceiver: 'slack-high'active_time_intervals:- business-hours# Route by team- match_re:team: platform.*receiver: 'platform-team'receivers:- name: 'default-receiver'slack_configs:- channel: '#alerts'send_resolved: true- name: 'pagerduty-critical'pagerduty_configs:- service_key: 'xxx'severity: criticaldescription: '{{ .CommonAnnotations.summary }}'details:firing: '{{ template "pagerduty.firing" . }}'- name: 'slack-high'slack_configs:- channel: '#alerts-high'title: '{{ .CommonAnnotations.summary }}'text: '{{ .CommonAnnotations.description }}'actions:- type: buttontext: 'Runbook'url: '{{ .CommonAnnotations.runbook_url }}'- type: buttontext: 'Dashboard'url: '{{ .CommonAnnotations.dashboard_url }}'- name: 'platform-team'slack_configs:- channel: '#platform-alerts'time_intervals:- name: business-hourstime_intervals:- weekdays: ['monday:friday']times:- start_time: '09:00'end_time: '17:00'inhibit_rules:- source_match:severity: criticaltarget_match:severity: highequal: ['service']
PagerDuty Integration
Service Configuration
# Terraform exampleresource "pagerduty_service" "myapp" {name = "MyApp Production"description = "Production application service"escalation_policy = pagerduty_escalation_policy.default.idalert_creation = "create_alerts_and_incidents"auto_resolve_timeout = 14400 # 4 hoursacknowledgement_timeout = 600 # 10 minutesincident_urgency_rule {type = "use_support_hours"during_support_hours {type = "constant"urgency = "high"}outside_support_hours {type = "constant"urgency = "low"}}}resource "pagerduty_escalation_policy" "default" {name = "Default Escalation"num_loops = 2rule {escalation_delay_in_minutes = 10target {type = "schedule_reference"id = pagerduty_schedule.primary.id}}rule {escalation_delay_in_minutes = 15target {type = "user_reference"id = pagerduty_user.manager.id}}}
Schedule Configuration
resource "pagerduty_schedule" "primary" {name = "Primary On-Call"time_zone = "America/New_York"layer {name = "Weekly Rotation"start = "2024-01-01T00:00:00-05:00"rotation_virtual_start = "2024-01-01T00:00:00-05:00"rotation_turn_length_seconds = 604800 # 1 weekusers = [for user in pagerduty_user.oncall : user.id]}# Override layer for holidayslayer {name = "Holiday Coverage"start = "2024-01-01T00:00:00-05:00"rotation_virtual_start = "2024-01-01T00:00:00-05:00"rotation_turn_length_seconds = 86400users = [pagerduty_user.holiday_coverage.id]restriction {type = "daily_restriction"start_time_of_day = "00:00:00"duration_seconds = 86400start_day_of_week = 0 # Sunday}}}
Grafana OnCall
Integration Setup
# docker-compose.yml additionservices:oncall:image: grafana/oncallenvironment:- SECRET_KEY=your-secret-key- BASE_URL=http://oncall:8080- GRAFANA_API_URL=http://grafana:3000ports:- "8080:8080"
Escalation Chain
# Example escalation chain structureescalation_chains:- name: "Production Critical"steps:- step: 1type: notifypersons:- "@oncall-primary"wait_delay: 0- step: 2type: notifypersons:- "@oncall-secondary"wait_delay: 5m- step: 3type: notifypersons:- "@engineering-manager"wait_delay: 10m- step: 4type: trigger_actionaction: "escalate_to_incident_commander"wait_delay: 15m
Alert Templates
Slack Alert Template
{{ define "slack.title" }}[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .CommonLabels.alertname }}{{ end }}{{ define "slack.text" }}{{ range .Alerts }}*Alert:* {{ .Annotations.summary }}*Severity:* {{ .Labels.severity }}*Description:* {{ .Annotations.description }}*Runbook:* {{ .Annotations.runbook_url }}{{ end }}{{ end }}
PagerDuty Details Template
{{ define "pagerduty.firing" }}{{ range .Alerts.Firing }}Alert: {{ .Labels.alertname }}Service: {{ .Labels.service }}Instance: {{ .Labels.instance }}Value: {{ .Annotations.value }}Started: {{ .StartsAt.Format "2006-01-02 15:04:05" }}{{ end }}{{ end }}
On-Call Best Practices
Rotation Guidelines
on_call_guidelines:rotation_length: 1 weekhandoff_time: "10:00 AM Monday"responsibilities:- Monitor alerts during shift- Respond within SLA (critical: 5min, high: 15min)- Document incidents- Handoff unresolved issuessupport:- Secondary on-call for backup- Clear escalation path- Manager availability for major incidentswellness:- Maximum 1 week on-call per month- Comp time after high-alert periods- No-interrupt recovery day after shift
Runbook Template
# Alert: High Error Rate## SummaryError rate has exceeded the threshold of 5% for the service.## ImpactUsers may experience errors when accessing the application.## Investigation Steps1.Check service logs: `kubectl logs -l app=myapp -n production`2.Review recent deployments: `kubectl rollout history deployment/myapp`3.Check database connectivity: `kubectl exec -it myapp -- nc -zv postgres 5432`4.Review error traces in APM dashboard## Remediation### If caused by recent deployment:
kubectl rollout undo deployment/myapp -n production
### If database related:
kubectl delete pod -l app=postgres -n production
## EscalationIf not resolved within 15 minutes, escalate to:- Database team: @db-oncall- Platform team: @platform-oncall
Alert Fatigue Reduction
Strategies
fatigue_reduction:aggregate_alerts:- Group related alerts- Use inhibit rules- Implement alert correlationtune_thresholds:- Base on SLOs, not arbitrary values- Account for normal variance- Use appropriate evaluation windowsautomate_responses:- Auto-remediation for known issues- Self-healing infrastructure- Automated scalingregular_review:- Weekly alert review- Remove unused alerts- Update thresholds based on data
Common Issues
Issue: Alert Storm
Problem: Too many alerts firing simultaneously Solution: Implement proper grouping and inhibition rules
Issue: Missed Alerts
Problem: Critical alerts not reaching on-call Solution: Test escalation policies, verify contact methods
Issue: False Positives
Problem: Alerts firing without actual issues Solution: Tune thresholds, increase evaluation windows
Best Practices
- Define clear severity levels
- Every alert needs a runbook
- Test on-call notifications regularly
- Review and tune alerts weekly
- Implement proper escalation paths
- Use alert grouping and inhibition
- Track alert metrics (MTTR, frequency)
- Practice incident response regularly
Related Skills
- prometheus-grafana - Monitoring setup
- incident-response - Incident handling
- runbook-creation - Runbook creation