Registry / devops / pino-lambda

pino-lambda

JSON →
library4.4.1jsnpmunverified

A custom Pino destination for AWS Lambda that reformats logs to match CloudWatch format, preserving @requestid, @timestamp, and @message properties for use with CloudWatch Insights, Datadog, and Splunk. Version 4.4.1, stable, semver releases. It automatically tracks request IDs, correlation IDs, and X-Ray tracing from upstream services. Ships TypeScript types.

npm install pino-lambda
INSTALL
IMPORT
SIG · PINO-LAMBDA
P
pino-lambda
devopsjavascriptv4.4.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pinoLambdaDestination
import { pinoLambdaDestination } from 'pino-lambda'
const pinoLambdaDestination = require('pino-lambda').pinoLambdaDestination
This is a named export. Also works with CommonJS require but prefers destructuring.
lambdaRequestTracker
import { lambdaRequestTracker } from 'pino-lambda'
import lambdaRequestTracker from 'pino-lambda'
LambdaRequestTracker is a named export, not default.
GlobalContextStorageProvider
import { GlobalContextStorageProvider } from 'pino-lambda'
const GlobalContextStorageProvider = require('pino-lambda').GlobalContextStorageProvider
Named export for updating context downstream.

Shows basic setup: create destination, attach to pino, track request context at handler start, then log.

import pino from 'pino'; import { lambdaRequestTracker, pinoLambdaDestination } from 'pino-lambda'; const destination = pinoLambdaDestination(); const logger = pino({}, destination); const withRequest = lambdaRequestTracker(); export const handler = async (event, context) => { withRequest(event, context); logger.info({ data: 'Some data' }, 'A log message'); };
Debug
Known issues
gotchapino-lambda requires pino >=6.0.0 and is not compatible with older pino versions. Ensure your pino version meets the peer dependency.
fix
Install pino@>=6.0.0: npm install pino@^6.0.0
affects: >=4.0.0
gotchaThe lambdaRequestTracker must be called once at the top of each Lambda handler invocation. Calling it multiple times or not calling it will result in missing context for log entries.
fix
Always call withRequest(event, context) at the start of the handler function.
affects: >=1.0.0
deprecatedUsing pinoLambdaDestination() without arguments is fine, but if you previously passed a custom stream, that pattern has changed in v4. The signature no longer accepts a stream parameter.
fix
Do not pass any argument to pinoLambdaDestination(). To customize output, use pino's own options or transports.
affects: >=4.0.0
gotchaThe destination reformats output to match CloudWatch format; if you rely on pino's default newline-delimited JSON, the output will be different. Ensure your log processing expects the CloudWatch format.
fix
Use pinoLambdaDestination() only in Lambda; for non-Lambda environments, use pino's default destination.
affects: >=1.0.0
deprecatedThe function 'lambdaRequestTracker' returns a tracker; using it as a decorator is deprecated. Prefer calling the returned function inside the handler.
fix
Use withRequest(event, context) directly inside handler body.
affects: >=2.0.0
Errors
Common errors & fixes
Cannot find module 'pino-lambda' or its corresponding type declarations.
Missing or outdated pino-lambda package; types not installed.
fix
Install pino-lambda: npm install pino-lambda. If using TypeScript, ensure types are included (they ship with the package).
TypeError: pinoLambdaDestination is not a function
Importing incorrectly using default import instead of named import.
fix
Use import { pinoLambdaDestination } from 'pino-lambda' (curly braces).
Error: pino-lambda: peer dependency pino@>=6.0.0 not installed
pino version is too low or not installed.
fix
Install pino>=6.0.0: npm install pino@^6.0.0
Logs not appearing in CloudWatch Insights correctly; @requestid missing
lambdaRequestTracker not called or called after logging.
fix
Ensure withRequest(event, context) is called before any logger.info() calls.
Upgrade
Version history
4.4.1latest on npm
Audit
Dependencies
pinorequiredPeer dependency required for logging; pino-lambda is a custom destination for pino.
Agent activity
8 hits · last 30 days
node
8
Resources
pino-lambda — npm install pino-lambda · libregistry