Skip to content

Monitoring guide

AWS Lambda monitoring

Lambda hides the servers, not the problems. Errors, throttles, cold starts and slow downstream calls still need watching, per function.

3 min read11 sectionsUpdated

On this page

Key points

  • Errors and Throttles per function are the first alerts.
  • Duration p95 against the timeout shows functions about to time out.
  • Cold starts show in the Init Duration of REPORT log lines.
  • OpenTelemetry layers add traces across functions and services.

Metrics to watch

MetricWorry when
ErrorsAbove 0 sustained, or above a small rate
ThrottlesAny: concurrency limit reached
Duration (p95, max)Approaching the configured timeout
ConcurrentExecutionsNear the account or reserved limit
IteratorAge (stream triggers)Growing: the function cannot keep up
DLQ / on-failure destination messagesAny

Cold starts

Each REPORT log line includes Init Duration when the invocation was a cold start. Large deployment packages, heavy imports and VPC setup lengthen it. Options: smaller packages, lazy imports, provisioned concurrency for latency-sensitive functions, and SnapStart where supported.

plaintext
REPORT RequestId: 3f1c... Duration: 182.43 ms Billed Duration: 183 ms Memory Size: 512 MB Max Memory Used: 141 MB Init Duration: 612.08 ms

Tracing

The OpenTelemetry Lambda layers (per language) instrument the handler and outgoing calls and export through an embedded Collector. Configure it to send traces to an OTLP endpoint; for VitalRix, the collector's otlphttp exporter with your API key, as in what is OTLP. Flush before the function returns, or spans can be lost when the environment freezes.

Lambda monitoring with VitalRix

Pull AWS/Lambda metrics through the CloudWatch integration and alert on errors, throttles and duration; send traces with OpenTelemetry for APM views per function; and add uptime checks on the API Gateway URLs that front them.

Structured logs from functions

Lambda writes everything you print to CloudWatch Logs. Write JSON lines with a request id and, when traced, the trace id, so a failed invocation's log lines can be found and linked to its trace. Keep debug output off by default; log volume is billed per GB ingested.

javascript
export const handler = async (event, context) => {
  console.log(JSON.stringify({ level: 'info', msg: 'order received', requestId: context.awsRequestId, orderId: event.orderId }));
  // ...
};

Concurrency and throttles

All functions in a region share the account's concurrency limit unless you reserve some for a function. A traffic spike in one function can throttle others. Reserve concurrency for critical functions, alert on Throttles for each, and watch ConcurrentExecutions against the account limit.

Frequently asked questions

How do I alert before a Lambda times out?

Alert when p95 or max duration exceeds about 80% of the configured timeout.

Does tracing add to cold starts?

Yes, a little: the layer and SDK initialize during the cold start. Measure Init Duration with and without it.

Check it now, free

  • What is a span in tracing?: What a span is in distributed tracing: its fields, parent and child spans, span kinds, attributes and status, with an annotated example you can read.
  • How to monitor a Next.js app: How to monitor a Next.js app in production: uptime checks, Core Web Vitals, server and edge errors, OpenTelemetry traces for SSR and API routes, and alerts.
  • OpenTelemetry for FastAPI: Trace a FastAPI service with OpenTelemetry: instrument the app, async database drivers and httpx, run uvicorn workers correctly and export.
  • OpenTelemetry for Go: Instrument a Go service with OpenTelemetry: set up the tracer provider, wrap net/http with otelhttp, pass context everywhere and export the spans.
  • OpenTelemetry for PHP and Laravel: Trace a Laravel app with OpenTelemetry: install the PHP extension and auto-instrumentation packages, configure PHP-FPM and trace queries.
  • OpenTelemetry for NestJS: Trace a NestJS service with OpenTelemetry: load the SDK before Nest boots, instrument HTTP, Express and NestJS core, and export JSON to VitalRix.

Watch your own site and services with VitalRix

Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.