__HTML_TAG_99_📄 Generare PagerDurata PDF Guida_HTML_TAG_100_
PagesDuty Cheatsheet¶
Installazione¶
CLI Tools Installazione¶
Tabella_103_
Pager # Installazione dell'agente Duty¶
Tabella_104_
Comandi di base¶
Autenticazione e configurazione¶
Tabella_105_
Gestione incidente¶
Tabella_106_
Service Management¶
Tabella_107_
User & On-Call Management¶
Tabella_108_
Pager # Comandi dell'agente dovere¶
Tabella_109_
Uso avanzato¶
Advanced Incident Operations¶
Tabella_110
REST API Operations (curl)¶
Tabella_111
Advanced Agent Operations¶
Tabella_112_
Gestione delle pianificazioni¶
Tabella_113_
Escalation Policy Management¶
Tabella_114_
Analytics & Reporting¶
Tabella_115
Configurazione¶
Variabili ambientali¶
# Set API token
export PDTOKEN="your_api_token_here"
# Set default region (for EU accounts)
export PD_API_BASE="https://api.eu.pagerduty.com"
# Set default user email
export PD_USER_EMAIL="user@example.com"
API Token Generation¶
- Accedi all'interfaccia web PagerDuty
- Navigare a **Configurazione → Accesso API **
- Fare clic *Crea nuova chiave API *
- Scegli "User Token" o "Account Token"
- Copia token e salva in modo sicuro
Integration Keys¶
# Integration keys are service-specific
# Find them at: Service → Integrations → Integration Key
# Use in agent:
pd-send -k "your_integration_key" -t trigger -d "Alert message"
# Use in Events API v2:
curl -X POST https://events.pagerduty.com/v2/enqueue \
-H "Content-Type: application/json" \
-d '{
"routing_key": "your_integration_key",
"event_action": "trigger",
"payload": {
"summary": "Server down",
"severity": "critical",
"source": "prod-server-01"
}
}'
Pagina Configurazione dell'agente dovere¶
# Agent config location: /etc/pdagent.conf
# View current configuration
cat /etc/pdagent.conf
# Common settings:
# - pid_file: /var/run/pdagent/pdagent.pid
# - log_dir: /var/log/pdagent
# - outqueue_dir: /var/lib/pdagent/outqueue
Esempio di configurazione del servizio¶
{
"service": {
"name": "Production API",
"description": "Main production API service",
"escalation_policy": {
"id": "ESCALATION_POLICY_ID",
"type": "escalation_policy_reference"
},
"alert_creation": "create_alerts_and_incidents",
"incident_urgency_rule": {
"type": "constant",
"urgency": "high"
},
"auto_resolve_timeout": 14400,
"acknowledgement_timeout": 1800
}
}
Common Use Cases¶
Use Case 1: Trigger and Resolve Incident from Monitoring¶
# Trigger incident when issue detected
pd-send -k R0123456789ABCDEF0123456789ABCDEF \
-t trigger \
-d "Database connection pool exhausted" \
-s critical \
-i db_pool_incident_001
# Add context as incident develops
pd-send -k R0123456789ABCDEF0123456789ABCDEF \
-t trigger \
-d "Connection count: 500/500" \
-i db_pool_incident_001
# Resolve when fixed
pd-send -k R0123456789ABCDEF0123456789ABCDEF \
-t resolve \
-i db_pool_incident_001
Use Case 2: Check Who's On-Call Before Deployment¶
# Get current on-call engineers
pd oncall:list --json | jq -r '.oncalls[] | "\(.escalation_policy.summary): \(.user.summary)"'
# Get on-call for specific escalation policy
pd oncall:list --escalation-policy-ids EP123456 --json | jq -r '.oncalls[].user.summary'
# Check schedule for next 7 days
pd schedule:show --id SCHEDULE_ID --since $(date -u +%Y-%m-%dT%H:%M:%SZ) --until $(date -u -d '+7 days' +%Y-%m-%dT%H:%M:%SZ)
Use Case 3: Bulk Incident Management durante l'estrazione¶
# Get all triggered incidents for a service
INCIDENTS=$(pd incident:list --service-ids SERVICE_ID --status triggered --json | jq -r '.incidents[].id')
# Acknowledge all incidents
echo "$INCIDENTS" | xargs -I {} pd incident:ack --id {}
# Add note to all incidents
echo "$INCIDENTS" | xargs -I {} pd incident:notes --id {} --note "Mass outage - investigating root cause"
# Resolve all incidents after fix
echo "$INCIDENTS" | xargs -I {} pd incident:resolve --id {}
Use Case 4: Create Incident with Conference Bridge¶
# Create high-priority incident with Zoom link
curl -X POST "https://api.pagerduty.com/incidents" \
-H "Authorization: Token token=$PDTOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/vnd.pagerduty+json;version=2" \
-H "From: oncall@example.com" \
-d '{
"incident": {
"type": "incident",
"title": "Production database outage",
"service": {
"id": "SERVICE_ID",
"type": "service_reference"
},
"urgency": "high",
"priority": {
"id": "PRIORITY_P1_ID",
"type": "priority_reference"
},
"body": {
"type": "incident_body",
"details": "Primary database cluster unresponsive"
},
"conference_bridge": {
"conference_number": "https://zoom.us/j/1234567890",
"conference_url": "https://zoom.us/j/1234567890"
}
}
}'
Use Case 5: Generate Weekly Incident Report¶
# Get incidents from last week
LAST_WEEK=$(date -u -d '7 days ago' +%Y-%m-%dT%H:%M:%SZ)
NOW=$(date -u +%Y-%m-%dT%H:%M:%SZ)
pd incident:list --since $LAST_WEEK --until $NOW --json | \
jq -r '.incidents[] | [.created_at, .urgency, .status, .title] | @csv' > weekly_incidents.csv
# Count incidents by service
pd incident:list --since $LAST_WEEK --until $NOW --json | \
jq -r '.incidents[] | .service.summary' | sort | uniq -c | sort -rn
# Calculate mean time to acknowledge
pd incident:list --since $LAST_WEEK --until $NOW --json | \
jq '[.incidents[] | select(.status == "resolved") |
(.first_trigger_log_entry.created_at as $trigger |
.acknowledgements[0].at as $ack |
($ack | fromdateiso8601) - ($trigger | fromdateiso8601))] |
add / length / 60' # Result in minutes
Migliori Pratiche¶
- Utilizzare le chiavi per la deduplica: Fornire sempre chiavi d'incidente coerenti (
-i_ flag) per evitare avvisi duplicati per lo stesso problema - **Set appropriate urgenze ** Utilizzare
highurgenza per problemi di produzione critici,lowper le notifiche non urgenti per evitare la fatica all'erta - Si'. Configurare i servizi con
auto_resolve_timeoutper chiudere automaticamente gli incidenti durante il monitoraggio mostra il recupero - ** Politiche di escalation ** Creare politiche di escalation multilivello per garantire incidenti raggiungere qualcuno che può rispondere
- Aggiungi il contesto agli incidenti: Includere dettagli rilevanti nelle descrizioni degli incidenti, note e campi personalizzati per accelerare la risoluzione
- Utilizzare gli overrides del programma: Pianifica per le vacanze e programma le modifiche creando override anziché modificare gli orari di base
- e classificare gli incidenti. Utilizzare tagging coerente per incidenti per consentire una migliore segnalazione e analisi della tendenza
- **Le integrazioni più frequenti ** Invia avvisi di prova per verificare che le integrazioni di monitoraggio funzionino correttamente
- Review incident analytics: Analisi regolare delle metriche MTTA (Mean Time to Acknowledge) e MTTR (Mean Time to Resolve)
- I libri di documenti... Collegare gli incidenti alle cartelle e alla documentazione per aiutare i rispondenti a risolvere rapidamente i problemi comuni
- ** Utilizzare pagine di stato**: Tenere le parti interessate informate collegando gli incidenti alle pagine di stato per la comunicazione trasparente
Risoluzione dei problemi¶
Tabella_116_¶
Quick Reference: Event Severity Levels¶
Tabella_117_
Quick Reference: Priorities Incident¶
| Priority | Response Time | Use Case |
|---|---|---|
| INLINE_CODE_91 | Immediate | Complete service outage, critical security incident |
| INLINE_CODE_92 | < 30 minutes | Major feature broken, significant performance degradation |
| INLINE_CODE_93 | < 2 hours | Minor feature issues, isolated customer impact |
| INLINE_CODE_94 | < 8 hours | Small bugs, cosmetic issues |
P5 |
Il prossimo giorno lavorativo | Richieste di potenziamento, aggiornamenti della documentazione |