Skip to main content

Observability by Design

Updated Sep 21, 2020 ·

Overview

Observability should be designed into the architecture before deployment, not added after the system is already running.

At minimum, the system should provide:

  • Logs for events, errors, and important state changes.
  • Metrics for infrastructure health, application performance, and business outcomes.
  • Traces for following requests across services.
  • Alerts for conditions that require action.

Good observability helps teams understand what the system is doing, investigate failures, measure user impact, and determine whether the architecture is meeting its requirements.

Three important observability decisions should be made before deployment:

AreaMain DecisionGoal
InstrumentationDecide what metrics, logs, and trace context the application should produceConnect technical behavior to application and business outcomes
AlertingDecide which conditions are important enough to trigger actionGenerate meaningful and actionable alerts
RetentionDecide which logs to retain, how long to retain them, and where to store themBalance operational needs, compliance requirements, and cost

Instrumentation

Infrastructure metrics are a starting point, but they do not provide the complete picture.

For example, high CPU utilization tells you that a container is busy. It does not tell you whether customers can successfully place orders or whether payments are failing.

Observability should therefore combine infrastructure telemetry with application-specific telemetry.

TypeExamplesPurpose
Infrastructure MetricsCPU, memory, request count, and network activityMeasure the health and utilization of infrastructure
Custom MetricsOrders per minute, payment failures per hour, and processing latencyMeasure application behavior and business outcomes
Structured LogsRequest details, application events, errors, and state changesProvide searchable context for troubleshooting
TracesTrace IDs, spans, service calls, and request durationFollow a request across multiple services

Infrastructure metrics are commonly emitted automatically by the platform. Custom metrics usually need to be identified and designed into the application.

Custom Metrics

Custom metrics should represent outcomes that matter to the application or business.

Useful examples include:

  • Orders completed per minute
  • Payment failures per hour
  • Authentication failures
  • Jobs successfully processed
  • Processing latency
  • API success rate
  • Queue processing time

A system can have healthy CPU and memory utilization while still failing its business purpose. Custom metrics help expose this difference.

Structured Logs and Trace Context

Logs become much more useful when they are structured and correlated with distributed traces.

Without trace IDs, a request passing through several services may produce thousands of unrelated log entries. Engineers must manually determine which entries belong to the same request.

With trace context, the same trace identifier can be propagated across services:

The trace ID can then be used to filter logs and reconstruct the complete request sequence across the system.

Trace context should be designed into the application from the beginning. Logs that were generated without trace information cannot later be automatically associated with a trace that was never recorded.

Alerting

Alerting should focus on conditions that require action.

Creating alerts for every unusual metric can lead to alert fatigue. When too many alerts are generated, engineers may begin ignoring them, including the important ones.

For example:

Alert TypeExampleProblem or Benefit
Raw ThresholdCPU > 80%May trigger during normal workloads such as batch processing
SLO Burn RateError budget is being consumed at 5 times the expected rateIndicates that a service commitment is at risk

A temporary CPU spike may be completely normal. An SLO error budget being consumed rapidly is more meaningful because it is connected to service reliability.

The goal is not simply to have fewer alerts. The goal is to have better signals.

SLI, SLO, and Burn Rate

Meaningful alerting can be built around a simple chain:

ConceptPurposeExample
SLIMeasures actual service behaviorPercentage of successful requests
SLODefines the expected service target99.9% successful requests
Error BudgetDefines how much failure is acceptable while still meeting the SLORemaining allowable failures
Burn RateMeasures how quickly the error budget is being consumed5 times the expected consumption rate

Burn-rate alerts help connect monitoring to an actual reliability commitment instead of an arbitrary infrastructure threshold.

For example:

Normal
Error budget burn rate: 1x
→ No alert

Abnormal
Error budget burn rate: 5x
→ Alert and investigate

Log Retention

Not all logs have the same value, and retaining logs has a cost.

Retention requirements should therefore be defined before deployment.

For each log type, determine:

  1. Which logs need to be collected.
  2. How long the logs need to be retained.
  3. Where the logs should be stored.
  4. How frequently the logs need to be queried.
  5. Whether regulatory or compliance requirements apply.

Operational logs may only need short-term retention, while audit logs may need to remain available for months or years.

Example: Google Cloud Logging and Log Sinks

Google Cloud Logging can collect logs centrally and use log sinks to route selected logs to other services.

DestinationTypical Purpose
Cloud StorageLong-term archival, compliance retention, and low-cost storage
BigQueryLog analysis, reporting, and audit queries
Pub/SubReal-time log processing, integrations, and alerting

Log sinks allow different categories of logs to follow different retention and processing strategies instead of treating every log identically.

Compliance and Audit Logs

For regulated workloads, log retention may be a requirement rather than an operational preference.

Examples include:

IndustryExample RequirementArchitectural Impact
HealthcareHIPAA audit trailsSecurity and audit logs may require defined retention and protection
FinancePCI DSS and SOX requirementsTransaction and audit records may require controlled retention
GovernmentFedRAMP requirementsLogging and retention requirements may be mandated

These requirements can affect storage architecture, access controls, retention periods, and deletion policies.

Compliance requirements should therefore be identified during architecture design rather than after deployment.

Operational Value

Observability is not just for troubleshooting.

It helps teams:

  1. Detect failures before they create significant user impact.
  2. Follow requests across distributed services.
  3. Determine whether failures are isolated or widespread.
  4. Measure application behavior instead of relying only on infrastructure health.
  5. Connect technical metrics to business outcomes.
  6. Determine whether SLOs are being met.
  7. Reduce alert fatigue by focusing on actionable signals.
  8. Support incident investigation and root cause analysis.
  9. Meet audit and compliance requirements.
  10. Control logging and retention costs.

The main principle is simple: observability is designed in, not switched on after the fact.