Idiomark - Operations Runbook
Last Updated: 2026-02-11 Maintainer: Operations Team On-Call: @idiomark-on-call
Table of Contents
- Overview
- Alerting & Monitoring
- Incident Response
- Common Operations
- Deployment
- Scaling Procedures
- Backup & Recovery
- Security Incidents
Overview
This runbook contains operational procedures for the Idiomark infrastructure. It is designed for on-call engineers responding to production incidents.
Infrastructure Components
| Component | Purpose | Owner |
|---|---|---|
| Web API | Extraction and analysis endpoints | Backend Team |
| Worker Pool | Async job processing | Platform Team |
| Cache Layer | Redis caching | Data Team |
| Database | Metadata storage | Data Team |
| CDN | Static asset delivery | Infra Team |
| Monitoring | Metrics and alerting | SRE Team |
Environments
| Environment | URL | Purpose |
|---|---|---|
| Production | api.idiomark.org | Live traffic |
| Staging | staging-api.idiomark.org | Pre-production testing |
| Development | dev.idiomark.org | Feature development |
Service Status
- Status Page: https://status.idiomark.org
- Incident Dashboard: https://grafana.idiomark.org/d/incidents
- Error Budget: https://grafana.idiomark.org/d/error-budget
Alerting & Monitoring
Alert Channels
| Channel | Purpose | Escalation |
|---|---|---|
#idiomark-alerts-critical | P0 incidents | Immediate (5 min) |
#idiomark-alerts-high | P1 incidents | 15 minutes |
#idiomark-alerts-info | P2+ incidents | 1 hour |
on-call@idiomark.org | Email / SMS | Critical only |
Alert Severity Levels
| Severity | Response Time | Example |
|---|---|---|
| P0 - Critical | 5 minutes | Complete service outage |
| P1 - High | 15 minutes | Significant degradation |
| P2 - Medium | 1 hour | Partial degradation |
| P3 - Low | Next business day | Minor issues |
Key Metrics
SLO Indicators
| Metric | SLO | Alert Threshold |
|---|---|---|
| API Availability | 99.9% | < 99.5% (P1) |
| API Latency (p95) | < 500ms | > 1000ms (P1) |
| API Latency (p99) | < 1000ms | > 2000ms (P2) |
| Error Rate | < 0.1% | > 0.5% (P1) |
| Worker Queue Depth | < 1000 | > 5000 (P2) |
Business Metrics
| Metric | Target | Alert Threshold |
|---|---|---|
| Extraction Success Rate | > 95% | < 90% (P2) |
| Analysis Accuracy | > 0.8 confidence | < 0.7 avg (P2) |
| Adapter Health | 100% | Any adapter unhealthy (P2) |
Dashboards
-
Main Dashboard: https://grafana.idiomark.org/d/main
- Request rate, latency, errors
- Adapter health
- Queue depth
-
LLM Usage: https://grafana.idiomark.org/d/llm
- Token consumption
- Cost tracking
- Provider health
-
Cache Performance: https://grafana.idiomark.org/d/cache
- Hit rate
- Memory usage
- Eviction rate
Incident Response
Incident Lifecycle
Detection → Triage → Response → Resolution → Post-Mortem
Step 1: Detection and Acknowledgment
When: PagerDuty / Slack alert fires
Actions:
- Acknowledge alert in Slack
- Join incident channel:
#idiomark-incident-{timestamp} - Set severity level based on impact
- Create incident ticket: https://idiomark.org/incidents/new
Severity Assessment:
| Criteria | Severity |
|---|---|
| Complete service outage, all users affected | P0 |
| Major degradation, most users affected | P1 |
| Partial degradation, some users affected | P2 |
| Minor issue, workarounds available | P3 |
Step 2: Triage
Goal: Understand scope and impact
Checklist:
- Verify alert is not false positive
- Determine affected users (all / subset)
- Check status page for recent changes
- Review error rate spike correlation
- Check recent deployments
Commands:
# Check recent deployments
idiomark-ops deployments recent
# Check error logs
idiomark-ops logs --since 1h --level error
# Check service health
idiomark-ops health --all
# Compare with baseline
idiomark-ops metrics compare --baseline 24h-ago
Step 3: Response
Goal: Restore service or implement workaround
Decision Tree:
Is the issue recent (< 1 hour)?
├─ Yes: Can we rollback last deployment?
│ ├─ Yes: Rollback → Verify → Document
│ └─ No: Continue investigation
└─ No: Continue investigation
Is a specific component failing?
├─ Yes: Can we restart the component?
│ ├─ Yes: Restart → Monitor → Document
│ └─ No: Check component-specific runbook
└─ No: Check dependency health
Is the issue related to external dependencies?
├─ Yes: Check provider status pages
│ ├─ Provider outage: Wait / Enable fallback
│ └─ Provider degradation: Enable caching
└─ No: Deep dive investigation required
Common Mitigations:
# Rollback deployment
idiomark-ops deployments rollback <version>
# Restart service
idiomark-ops services restart --service api
# Enable maintenance mode
idiomark-ops maintenance enable --reason "Investigating issues"
# Scale up workers
idiomark-ops workers scale --replicas 10
# Clear cache (if cache corruption suspected)
idiomark-ops cache flush --all
Step 4: Resolution
Goal: Confirm service is restored
Verification Checklist:
- Primary metrics恢复正常
- Error rate below threshold
- No active alerts firing
- Sample requests succeed
- Internal smoke tests pass
Commands:
# Run smoke tests
idiomark-ops test smoke
# Verify health endpoints
curl https://api.idiomark.org/health
# Check recent logs for errors
idiomark-ops logs --since 5m --level error
Step 5: Post-Incident
Goal: Learn and prevent recurrence
Actions:
- Update incident ticket with timeline
- Draft post-mortem document
- Schedule post-mortem meeting (if P0/P1)
- Create follow-up tasks
- Update runbook if new procedure discovered
Post-Mortem Template:
# Post-Mortem: {Incident Title}
**Date**: YYYY-MM-DD
**Severity**: P0 / P1 / P2 / P3
**Duration**: X hours
**Incident ID**: INC-{number}
## Summary
[2-3 sentence summary of what happened and impact]
## Timeline
| Time (UTC) | Event |
|-------------|--------|
| 14:23 | Alert fired |
| 14:25 | Incident declared |
| ... | ... |
## Root Cause
[What caused the incident? Use 5 Whys if needed]
## Resolution
[How was it fixed?]
## Impact
- **Users Affected**: {number or percentage}
- **Duration**: {time}
- **Error Budget Consumed**: {percentage}
## Follow-up Actions
| Action | Owner | Due Date |
|--------|--------|----------|
| ... | ... | ... |
Common Operations
Health Checks
Check All Services
idiomark-ops health check --all
# Output example:
# ✓ API: healthy (latency: 45ms)
# ✓ Workers: healthy (12/12 replicas)
# ✓ Cache: healthy (hit rate: 87%)
# ✓ Database: healthy (connections: 45/100)
# ⚠ GitHub Adapter: rate limited (resets in 5m)
Check Specific Service
idiomark-ops health check --service api
idiomark-ops health check --service workers
idiomark-ops health check --adapter github
Log Access
Recent Logs
# Last 100 lines
idiomark-ops logs tail
# Filter by level
idiomark-ops logs tail --level error
# Filter by service
idiomark-ops logs tail --service api
# Since specific time
idiomark-ops logs tail --since 1h
Log Search
# Search for errors
idiomark-ops logs search "ERROR"
# Search with context
idiomark-ops logs search "timeout" --context 5
# Search time range
idiomark-ops logs search "failed" --from "2025-02-11T10:00:00Z" --to "2025-02-11T12:00:00Z"
Metrics Access
Current Metrics
# API metrics
idiomark-ops metrics api
# Output:
# Requests/sec: 145
# p50 Latency: 45ms
# p95 Latency: 234ms
# p99 Latency: 567ms
# Error Rate: 0.05%
# Worker metrics
idiomark-ops metrics workers
# Output:
# Queue Depth: 234
# Processing Rate: 45/sec
# Avg Job Duration: 12.3s
Historical Metrics
# Compare with baseline
idiomark-ops metrics compare --baseline yesterday
# Custom time range
idiomark-ops metrics query "rate(requests[5m])" --from 1h ago
# Top errors
idiomark-ops metrics errors --top 10
Cache Operations
View Cache Stats
idiomark-ops cache stats
# Output:
# Memory: 1.2GB / 4GB (30%)
# Hit Rate: 87.3%
# Keys: 1,234,567
# Evictions: 456
Flush Cache
# Flush all cache
idiomark-ops cache flush --all
# Flush specific pattern
idiomark-ops cache flush --pattern "github:*"
# Flush expired only
idiomark-ops cache flush --expired
Warm Cache
# Pre-load common queries
idiomark-ops cache warm --sources github,twitter --samples 100
Adapter Operations
Check Adapter Health
idiomark-ops adapters health
# Output:
# github: ✓ healthy (rate limit: 4873/5000)
# twitter: ✓ healthy (rate limit: 87/100)
# reddit: ⚠ degraded (high latency: 2.3s)
Test Adapter
idiomark-ops adapters test github --auth token=xxx
# Output:
# ✓ Authentication: passed
# ✓ Fetch content: passed (234 items)
# ✓ Normalize: passed
# Performance: OK (avg: 234ms)
Disable/Enable Adapter
# Disable adapter globally
idiomark-ops adapters disable github --reason "Rate limit issues"
# Enable adapter
idiomark-ops adapters enable github
# View disabled adapters
idiomark-ops adapters list --disabled
Deployment
Deployment Process
Pre-Deployment Checklist
- All tests passing in CI
- Code reviewed and approved
- Changelog updated
- No active P0/P1 incidents
- Staging deployment verified
- Rollback plan documented
Deployment Commands
# Deploy to staging
idiomark-ops deploy --env staging --version 1.2.3
# Verify staging
idiomark-ops test smoke --env staging
# Deploy to production
idiomark-ops deploy --env production --version 1.2.3
# Monitor deployment
idiomark-ops deployments status --env production
Deployment Verification
# Check version
curl https://api.idiomark.org/version
# Run smoke tests
idiomark-ops test smoke --env production
# Check error rate
idiomark-ops metrics errors --since 5m
# Rollback if issues
idiomark-ops deployments rollback --env production
Deployment Strategies
Rolling Deployment (Default)
idiomark-ops deploy --strategy rolling --replicas 10
Process: Replace 2 replicas at a time, verify health, continue.
Duration: ~5 minutes for 10 replicas
Rollback: 2 minutes
Blue-Green Deployment
idiomark-ops deploy --strategy blue-green
Process: Deploy to new infrastructure, verify, switch traffic.
Duration: ~10 minutes
Rollback: Instant (traffic switch)
Canary Deployment
idiomark-ops deploy --strategy canary --percentage 10
Process: Deploy to 10% of traffic, monitor, gradually increase.
Duration: ~30 minutes (with monitoring)
Rollback: Instant (percentage adjustment)
Scaling Procedures
Horizontal Scaling
Scale API Servers
# Scale to specific replica count
idiomark-ops scale api --replicas 20
# Auto-scale based on CPU
idiomark-ops scale api --auto --min 5 --max 50 --target-cpu 70
Scale Workers
# Scale worker pool
idiomark-ops scale workers --replicas 50
# Scale based on queue depth
idiomark-ops scale workers --auto --queue-threshold 1000
Vertical Scaling
# Upgrade instance type
idiomark-ops instances upgrade --service api --type m5.2xlarge
# Apply changes
idiomark-ops instances apply --rolling
Database Scaling
Read Replicas
# Add read replica
idiomark-ops database add-replica --region us-west-2
# Promote replica to primary
idiomark-ops database promote --replica replica-2
Connection Pooling
# Update connection limits
idiomark-ops database config --max-connections 500 --pool-size 100
Cache Scaling
# Scale Redis cluster
idiomark-ops cache scale --cluster-mode replication --shards 8
# Add Redis node
idiomark-ops cache add-node --region eu-west-1
Backup & Recovery
Backup Schedule
| Data Type | Frequency | Retention |
|---|---|---|
| Database | Hourly | 30 days |
| Cache | Daily | 7 days |
| Logs | Continuous | 90 days |
| Idiomark Files | On-demand | Forever (user-owned) |
Backup Operations
Create Backup
# Database backup
idiomark-ops backup database --name "pre-deploy-$(date +%Y%m%d)"
# Cache backup
idiomark-ops backup cache
# Configuration backup
idiomark-ops backup config --include-secrets
List Backups
idiomark-ops backup list
# Output:
# ID: backup-20250211-001 | Type: database | Size: 2.3GB | Date: 2025-02-11 10:00:00
# ID: backup-20250211-002 | Type: cache | Size: 1.1GB | Date: 2025-02-11 11:00:00
Recovery Procedures
Database Recovery
# List available backups
idiomark-ops backup list --type database
# Restore specific backup
idiomark-ops backup restore backup-20250211-001 --env staging
# Point-in-time recovery
idiomark-ops backup restore --to "2025-02-11T10:30:00Z"
Cache Recovery
# Cache is ephemeral - flush and rebuild
idiomark-ops cache flush --all
# Warm cache from common queries
idiomark-ops cache warm --sources github,twitter --samples 1000
Disaster Recovery
Scenario: Complete region failure
# Activate DR region
idiomark-ops dr activate --region eu-west-1
# Verify DR environment
idiomark-ops health check --region eu-west-1
# Switch DNS
idiomark-ops dns switch --region eu-west-1
# Monitor
idiomark-ops metrics watch --region eu-west-1
Security Incidents
Incident Classification
| Type | Response Time | Escalation |
|---|---|---|
| Data Breach | Immediate | C-Suite, Legal |
| Unauthorized Access | 15 minutes | Security Team Lead |
| DDoS Attack | 5 minutes | CTO, Infra Lead |
| Vulnerability Disclosure | 24 hours | Security Team |
Security Response Procedures
Active Attack
# Enable incident mode
idiomark-ops security incident-mode enable --reason "Active attack detected"
# Block malicious IPs
idiomark-ops firewall block --ip 192.168.1.100 --reason "Attack source"
# Enable rate limiting
idiomark-ops security rate-limit --threshold 10/minute
# Enable CAPTCHA
idiomark-ops security captcha enable
# Scale for DDoS resilience
idiomark-ops scale api --replicas 100
Data Breach Response
-
Containment (0-30 minutes)
- Identify affected systems
- Isate affected systems
- Preserve evidence
-
Investigation (30 min - 24 hours)
- Determine breach scope
- Identify affected data
- Assess impact
-
Notification (24-72 hours)
- Legal review
- User notification
- Regulatory filing (if required)
-
Remediation (1-7 days)
- Patch vulnerabilities
- Enhance monitoring
- Update policies
Security Audits
# Run security scan
idiomark-ops security scan --type vulnerability
# Check for secrets in code
idiomark-ops security scan --type secrets
# Compliance check
idiomark-ops security compliance --standard SOC2
Runbook Maintenance
Update Procedures
When to update this runbook:
- After any major incident
- When new procedures are added
- When architecture changes
- Quarterly review
Update Process:
- Create branch:
runbook/update-{date} - Edit relevant sections
- Submit PR with
runbooklabel - Review and approve
- Merge and deploy
Emergency Contacts
| Role | Name | Contact |
|---|---|---|
| On-Call Engineer | [Name] | +1 (555) XXX-XXXX |
| Engineering Lead | [Name] | +1 (555) XXX-XXXX |
| CTO | [Name] | +1 (555) XXX-XXXX |
| Legal | legal@idiomark.org | legal@idiomark.org |
External Contacts
| Service | Contact |
|---|---|
| Cloud Provider | AWS Support: 1-800-XXX-XXXX |
| CDN Provider | Cloudflare: support@cloudflare.com |
| LLM Provider - Anthropic | support@anthropic.com |
| LLM Provider - OpenAI | support@openai.com |
For questions about this runbook, contact: ops@idiomark.org