Observability Design
Purpose
Design a comprehensive observability strategy covering metrics, logging, tracing, alerting, and SLI/SLO definitions. Produces a monitoring architecture that enables rapid incident detection, diagnosis, and resolution.
Inputs
- System architecture (services, databases, APIs, third-party dependencies)
- Current monitoring setup (existing tools, dashboards, alerts)
- Reliability requirements (SLA commitments, uptime targets)
- Team structure (on-call rotation, escalation paths)
Process
Step 1: Define Observability Pillars
Establish the three pillars for this system:
- Metrics: What to measure — request rate, error rate, latency, saturation, business KPIs
- Logs: What to record — request lifecycle, state changes, errors, audit events
- Traces: What to follow — cross-service request flows, database queries, external API calls
- Map each pillar to specific use cases: debugging, alerting, capacity planning, business intelligence
Step 2: Design Metric Collection
Define the metric taxonomy:
- Application metrics: Request count, error count, latency histograms, queue depth, cache hit rate
- Infrastructure metrics: CPU, memory, disk I/O, network throughput, connection pool utilization
- Business metrics: Sign-ups, conversions, revenue events, feature adoption rates
- Custom instrumentation: Counters (events), gauges (current values), histograms (distributions)
- Specify metric naming conventions, label/tag strategy, and cardinality limits
Step 3: Define Alert Thresholds and Escalation
Design the alerting strategy:
- Warning alerts: Early indicators — elevated error rate, latency creep, resource approaching limits
- Critical alerts: Immediate action required — service down, error rate spike, SLO burn rate exceeded
- Escalation paths: Primary on-call → secondary → engineering lead → incident commander
- Runbook links: Every alert includes a link to its diagnosis and remediation runbook
- Alert fatigue prevention: Grouping, deduplication, silence windows, alert quality reviews
Step 4: Plan Structured Logging
Design the logging architecture:
- Log levels: DEBUG (development only), INFO (normal operations), WARN (unexpected but handled), ERROR (requires attention)
- Structured fields: timestamp, service, request_id, user_id, action, duration_ms, status
- Correlation IDs: Request ID propagation across services for distributed request tracing
- PII redaction: Identify sensitive fields, implement automatic redaction/masking
- Log aggregation: Collection, indexing, retention periods, search capabilities
Step 5: Design Distributed Tracing
Plan request flow visibility:
- Span naming conventions:
service.operation format, consistent across services
- Context propagation: How trace context passes between services (headers, message metadata)
- Sampling strategy: Head-based vs tail-based sampling, sampling rate by endpoint or error status
- Trace enrichment: Adding business context (user tier, feature flag state) to spans
- Critical paths: Which request flows must always be traced (payments, auth, data mutations)
Step 6: Specify Dashboard Requirements
Define dashboard hierarchy:
- Operational dashboards: Service health overview, real-time traffic, error rates, latency percentiles
- Business dashboards: User activity, feature adoption, conversion funnels, revenue metrics
- SLO dashboards: Error budget remaining, burn rate, SLO compliance history
- Incident dashboards: Pre-built investigation views for common failure modes
- Specify dashboard layout, refresh intervals, time range defaults, and access controls
Step 7: Define SLIs/SLOs
Establish reliability targets:
- Availability SLI: Successful requests / total requests (define "successful")
- Latency SLI: Proportion of requests faster than threshold (p50, p95, p99 targets)
- Error rate SLI: Proportion of requests without errors (define "error")
- SLO targets: e.g., 99.9% availability, p95 latency < 200ms, error rate < 0.1%
- Error budgets: Calculate error budget from SLO, define burn rate alerts (fast burn, slow burn)
- SLO review cadence: Weekly error budget check, monthly SLO review, quarterly target adjustment
Output Format
# Observability Design: [Service/Feature Name]
## Observability Architecture
[Application] → [Metrics Agent] → [Metrics Store] → [Dashboards]
↓ ↓
[Structured Logs] → [Log Aggregator] → [Log Search] [Alerts] → [On-call]
↓
[Trace SDK] → [Trace Collector] → [Trace UI]
## Metric Catalog
| Metric Name | Type | Labels | Description | Alert Threshold |
|-------------|------|--------|-------------|-----------------|
| http_requests_total | counter | method, path, status | Request count | N/A |
| http_request_duration_ms | histogram | method, path | Request latency | p95 > 500ms |
| ... | ... | ... | ... | ... |
## Alert Catalog
| Alert Name | Severity | Condition | Duration | Runbook |
|------------|----------|-----------|----------|---------|
| HighErrorRate | critical | error_rate > 5% | 5m | [link] |
| LatencyDegraded | warning | p95 > 500ms | 10m | [link] |
| ... | ... | ... | ... | ... |
## Logging Schema
```json
{
"timestamp": "ISO8601",
"level": "INFO",
"service": "api",
"request_id": "uuid",
"user_id": "string (optional)",
"action": "string",
"duration_ms": "number",
"status": "number",
"message": "string"
}
SLI/SLO Definitions
| SLI |
Measurement |
SLO Target |
Error Budget (30d) |
| Availability |
successful requests / total |
99.9% |
43.2 min downtime |
| Latency |
requests < 200ms / total |
99.0% |
432 min slow |
| Error Rate |
non-error requests / total |
99.9% |
0.1% errors |
Dashboard Specifications
| Dashboard |
Audience |
Key Panels |
Refresh |
| Service Health |
On-call |
Traffic, errors, latency, saturation |
30s |
| SLO Status |
Engineering |
Error budget, burn rate, compliance |
5m |
| Business Metrics |
Product |
Adoption, conversions, revenue |
1h |
## Quality Checks
- [ ] All three observability pillars (metrics, logs, traces) are covered
- [ ] Every alert has a defined severity, threshold, and linked runbook
- [ ] Structured logging schema includes correlation IDs for distributed tracing
- [ ] PII fields are identified with redaction strategy
- [ ] SLIs are measurable and SLO targets are realistic for the service tier
- [ ] Error budgets are calculated with burn rate alert thresholds
- [ ] Dashboard hierarchy covers operational, business, and SLO views
- [ ] Sampling strategy balances trace coverage with storage costs
## Evolution Notes
<!-- Observations appended after each use -->
1---2name: observability-design3department: "operator"4description: "Monitoring, alerting, and logging strategy with SLI/SLO definitions"5version: 16triggers:7 - "monitoring"8 - "alerting"9 - "logging"10 - "observability"11 - "Sentry"12 - "metrics"13 - "tracing"14 - "dashboard"15 - "SLO"16---1718# Observability Design1920## Purpose2122Design a comprehensive observability strategy covering metrics, logging, tracing, alerting, and SLI/SLO definitions. Produces a monitoring architecture that enables rapid incident detection, diagnosis, and resolution.2324## Inputs2526- System architecture (services, databases, APIs, third-party dependencies)27- Current monitoring setup (existing tools, dashboards, alerts)28- Reliability requirements (SLA commitments, uptime targets)29- Team structure (on-call rotation, escalation paths)3031## Process3233### Step 1: Define Observability Pillars3435Establish the three pillars for this system:36- **Metrics**: What to measure — request rate, error rate, latency, saturation, business KPIs37- **Logs**: What to record — request lifecycle, state changes, errors, audit events38- **Traces**: What to follow — cross-service request flows, database queries, external API calls39- Map each pillar to specific use cases: debugging, alerting, capacity planning, business intelligence4041### Step 2: Design Metric Collection4243Define the metric taxonomy:44- **Application metrics**: Request count, error count, latency histograms, queue depth, cache hit rate45- **Infrastructure metrics**: CPU, memory, disk I/O, network throughput, connection pool utilization46- **Business metrics**: Sign-ups, conversions, revenue events, feature adoption rates47- **Custom instrumentation**: Counters (events), gauges (current values), histograms (distributions)48- Specify metric naming conventions, label/tag strategy, and cardinality limits4950### Step 3: Define Alert Thresholds and Escalation5152Design the alerting strategy:53- **Warning alerts**: Early indicators — elevated error rate, latency creep, resource approaching limits54- **Critical alerts**: Immediate action required — service down, error rate spike, SLO burn rate exceeded55- **Escalation paths**: Primary on-call → secondary → engineering lead → incident commander56- **Runbook links**: Every alert includes a link to its diagnosis and remediation runbook57- **Alert fatigue prevention**: Grouping, deduplication, silence windows, alert quality reviews5859### Step 4: Plan Structured Logging6061Design the logging architecture:62- **Log levels**: DEBUG (development only), INFO (normal operations), WARN (unexpected but handled), ERROR (requires attention)63- **Structured fields**: timestamp, service, request_id, user_id, action, duration_ms, status64- **Correlation IDs**: Request ID propagation across services for distributed request tracing65- **PII redaction**: Identify sensitive fields, implement automatic redaction/masking66- **Log aggregation**: Collection, indexing, retention periods, search capabilities6768### Step 5: Design Distributed Tracing6970Plan request flow visibility:71- **Span naming conventions**: `service.operation` format, consistent across services72- **Context propagation**: How trace context passes between services (headers, message metadata)73- **Sampling strategy**: Head-based vs tail-based sampling, sampling rate by endpoint or error status74- **Trace enrichment**: Adding business context (user tier, feature flag state) to spans75- **Critical paths**: Which request flows must always be traced (payments, auth, data mutations)7677### Step 6: Specify Dashboard Requirements7879Define dashboard hierarchy:80- **Operational dashboards**: Service health overview, real-time traffic, error rates, latency percentiles81- **Business dashboards**: User activity, feature adoption, conversion funnels, revenue metrics82- **SLO dashboards**: Error budget remaining, burn rate, SLO compliance history83- **Incident dashboards**: Pre-built investigation views for common failure modes84- Specify dashboard layout, refresh intervals, time range defaults, and access controls8586### Step 7: Define SLIs/SLOs8788Establish reliability targets:89- **Availability SLI**: Successful requests / total requests (define "successful")90- **Latency SLI**: Proportion of requests faster than threshold (p50, p95, p99 targets)91- **Error rate SLI**: Proportion of requests without errors (define "error")92- **SLO targets**: e.g., 99.9% availability, p95 latency < 200ms, error rate < 0.1%93- **Error budgets**: Calculate error budget from SLO, define burn rate alerts (fast burn, slow burn)94- **SLO review cadence**: Weekly error budget check, monthly SLO review, quarterly target adjustment9596## Output Format9798```markdown99# Observability Design: [Service/Feature Name]100101## Observability Architecture102103```104[Application] → [Metrics Agent] → [Metrics Store] → [Dashboards]105 ↓ ↓106[Structured Logs] → [Log Aggregator] → [Log Search] [Alerts] → [On-call]107 ↓108[Trace SDK] → [Trace Collector] → [Trace UI]109```110111## Metric Catalog112113| Metric Name | Type | Labels | Description | Alert Threshold |114|-------------|------|--------|-------------|-----------------|115| http_requests_total | counter | method, path, status | Request count | N/A |116| http_request_duration_ms | histogram | method, path | Request latency | p95 > 500ms |117| ... | ... | ... | ... | ... |118119## Alert Catalog120121| Alert Name | Severity | Condition | Duration | Runbook |122|------------|----------|-----------|----------|---------|123| HighErrorRate | critical | error_rate > 5% | 5m | [link] |124| LatencyDegraded | warning | p95 > 500ms | 10m | [link] |125| ... | ... | ... | ... | ... |126127## Logging Schema128129```json130{131 "timestamp": "ISO8601",132 "level": "INFO",133 "service": "api",134 "request_id": "uuid",135 "user_id": "string (optional)",136 "action": "string",137 "duration_ms": "number",138 "status": "number",139 "message": "string"140}141```142143## SLI/SLO Definitions144145| SLI | Measurement | SLO Target | Error Budget (30d) |146|-----|-------------|------------|-------------------|147| Availability | successful requests / total | 99.9% | 43.2 min downtime |148| Latency | requests < 200ms / total | 99.0% | 432 min slow |149| Error Rate | non-error requests / total | 99.9% | 0.1% errors |150151## Dashboard Specifications152153| Dashboard | Audience | Key Panels | Refresh |154|-----------|----------|------------|---------|155| Service Health | On-call | Traffic, errors, latency, saturation | 30s |156| SLO Status | Engineering | Error budget, burn rate, compliance | 5m |157| Business Metrics | Product | Adoption, conversions, revenue | 1h |158```159160## Quality Checks161162- [ ] All three observability pillars (metrics, logs, traces) are covered163- [ ] Every alert has a defined severity, threshold, and linked runbook164- [ ] Structured logging schema includes correlation IDs for distributed tracing165- [ ] PII fields are identified with redaction strategy166- [ ] SLIs are measurable and SLO targets are realistic for the service tier167- [ ] Error budgets are calculated with burn rate alert thresholds168- [ ] Dashboard hierarchy covers operational, business, and SLO views169- [ ] Sampling strategy balances trace coverage with storage costs170171## Evolution Notes172<!-- Observations appended after each use -->