Skip to main content

Idiomark - Operations Runbook

Last Updated: 2026-02-11 Maintainer: Operations Team On-Call: @idiomark-on-call

Table of Contents​

  1. Overview
  2. Alerting & Monitoring
  3. Incident Response
  4. Common Operations
  5. Deployment
  6. Scaling Procedures
  7. Backup & Recovery
  8. 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​

ComponentPurposeOwner
Web APIExtraction and analysis endpointsBackend Team
Worker PoolAsync job processingPlatform Team
Cache LayerRedis cachingData Team
DatabaseMetadata storageData Team
CDNStatic asset deliveryInfra Team
MonitoringMetrics and alertingSRE Team

Environments​

EnvironmentURLPurpose
Productionapi.idiomark.orgLive traffic
Stagingstaging-api.idiomark.orgPre-production testing
Developmentdev.idiomark.orgFeature development

Service Status​


Alerting & Monitoring​

Alert Channels​

ChannelPurposeEscalation
#idiomark-alerts-criticalP0 incidentsImmediate (5 min)
#idiomark-alerts-highP1 incidents15 minutes
#idiomark-alerts-infoP2+ incidents1 hour
on-call@idiomark.orgEmail / SMSCritical only

Alert Severity Levels​

SeverityResponse TimeExample
P0 - Critical5 minutesComplete service outage
P1 - High15 minutesSignificant degradation
P2 - Medium1 hourPartial degradation
P3 - LowNext business dayMinor issues

Key Metrics​

SLO Indicators​

MetricSLOAlert Threshold
API Availability99.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​

MetricTargetAlert Threshold
Extraction Success Rate> 95%< 90% (P2)
Analysis Accuracy> 0.8 confidence< 0.7 avg (P2)
Adapter Health100%Any adapter unhealthy (P2)

Dashboards​

  1. Main Dashboard: https://grafana.idiomark.org/d/main

    • Request rate, latency, errors
    • Adapter health
    • Queue depth
  2. LLM Usage: https://grafana.idiomark.org/d/llm

    • Token consumption
    • Cost tracking
    • Provider health
  3. 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:

  1. Acknowledge alert in Slack
  2. Join incident channel: #idiomark-incident-{timestamp}
  3. Set severity level based on impact
  4. Create incident ticket: https://idiomark.org/incidents/new

Severity Assessment:

CriteriaSeverity
Complete service outage, all users affectedP0
Major degradation, most users affectedP1
Partial degradation, some users affectedP2
Minor issue, workarounds availableP3

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:

  1. Update incident ticket with timeline
  2. Draft post-mortem document
  3. Schedule post-mortem meeting (if P0/P1)
  4. Create follow-up tasks
  5. 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
# 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 TypeFrequencyRetention
DatabaseHourly30 days
CacheDaily7 days
LogsContinuous90 days
Idiomark FilesOn-demandForever (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​

TypeResponse TimeEscalation
Data BreachImmediateC-Suite, Legal
Unauthorized Access15 minutesSecurity Team Lead
DDoS Attack5 minutesCTO, Infra Lead
Vulnerability Disclosure24 hoursSecurity 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​

  1. Containment (0-30 minutes)

    • Identify affected systems
    • Isate affected systems
    • Preserve evidence
  2. Investigation (30 min - 24 hours)

    • Determine breach scope
    • Identify affected data
    • Assess impact
  3. Notification (24-72 hours)

    • Legal review
    • User notification
    • Regulatory filing (if required)
  4. 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:​

  1. Create branch: runbook/update-{date}
  2. Edit relevant sections
  3. Submit PR with runbook label
  4. Review and approve
  5. Merge and deploy

Emergency Contacts​

RoleNameContact
On-Call Engineer[Name]+1 (555) XXX-XXXX
Engineering Lead[Name]+1 (555) XXX-XXXX
CTO[Name]+1 (555) XXX-XXXX
Legallegal@idiomark.orglegal@idiomark.org

External Contacts​

ServiceContact
Cloud ProviderAWS Support: 1-800-XXX-XXXX
CDN ProviderCloudflare: support@cloudflare.com
LLM Provider - Anthropicsupport@anthropic.com
LLM Provider - OpenAIsupport@openai.com

For questions about this runbook, contact: ops@idiomark.org