020. Observability: Powertools Logger + EMF + per-env alarms
- Date: 2026-11-17
- Status: Accepted
- Supersedes: RAG008. Observability: AWS-native CloudWatch + X-Ray + Lambda Powertools
- Builds on: RAG002. Backend application stack and tooling, RAG004. Lambda ASGI adapter - Mangum, RAG001. Environment topology: QA and Prod separate VPCs, RAG009. API authentication: bearer-token Lambda authorizer + Aurora-backed key store
Decision
Section titled “Decision”In the context ofa FastAPI-on-Lambda API and a bearer-token authorizer (RAG002, RAG004, RAG009) behind API Gateway, calling Aurora through the RDS Data API and Bedrock through its public endpoint, deployed per environment (RAG001) and operated by one person,facinga ranking of low cost first and low maintenance second, a question log whose retention is a data-handling commitment, abuse and failure modes that a single error-rate alarm does not see (request floods on unauthenticated routes, authorizer stalls, a database that never pauses), and the X-Ray SDK (Powertools Tracer), reaching end of support on 2027-02-25,we decided foran AWS-native stack without tracing:- AWS Lambda Powertools for Python Logger for structured JSON logs, with the API Gateway request ID (
requestContext.requestId) injected in the API and authorizer Lambdas and logged ascorrelation_id, so app logs join the API access log, - Powertools Metrics, emitting CloudWatch Embedded Metric Format (EMF) records for trace-like signals, such as per-hop latency (Bedrock generation, guardrail checks, Data API) and token counts,
- explicit retention on log groups set per environment root,
- CloudWatch alarms, all publishing to one SNS topic which emails the operator,
- distributed tracing deferred,
- AWS Lambda Powertools for Python Logger for structured JSON logs, with the API Gateway request ID (
and neglected- Powertools Tracer with X-Ray, as RAG008 decided: hitting end of support, and moving to OpenTelemetry would add a collector layer,
- Lambda-native active tracing (
tracing_configActive, no SDK or daemon in the function): without downstream subsegments for Bedrock and the Data API, it adds little over request-ID-correlated logs and EMF latency metrics, - a per-environment CloudWatch dashboard: high maintenance but not impactful
- a hard-coded retention figure in each module: it drifts,
- one SNS topic per environment: two subscriptions to confirm, and account-level budgets have no environment to publish to,
- third-party observability (Datadog, Grafana Cloud, Honeycomb): each adds a vendor account, a stored API key, and an outbound destination, disproportionate for a personal demo,
to achieve- a near-zero observability bill with no new vendor,
- alerts that reach the operator for spend, abuse, and failure through one channel,
- log retention that is bounded and stated once,
accepting- no trace view: diagnosing a slow request means reading per-hop latency metrics and joining logs on the request ID,
- CloudWatch’s utilitarian UI and Logs Insights as the only query surface,
- alarms only detect; stopping spend is RAG021’s concern.
Consequences
Section titled “Consequences”Every EMF dimension takes values from a fixed set: the service name is constant per function, and routes come from a fixed list. The per-environment metric namespace separates environments, so environment is not a dimension. Each unique dimension combination is a separately billed custom metric, so request IDs and key labels go in logs only. Non-Lambda tooling (the OpenAPI export script, the ingestion CLI) logs JSON to stdout.
© 2026 Benjamin Arunski