npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@hirotoshioi/winston-cloudwatch-logs

v0.2.1

Published

Send logs to Amazon Cloudwatch Logs using [Winston](https://github.com/winstonjs/winston).

Readme

winston-cloudwatch-logs

Send logs to Amazon Cloudwatch Logs using Winston.

Table of Contents

Features

  • Automatic Log Stream Management: Creates new log streams based on the current UTC date and hour, prefixed by your logStreamNamePrefix. This helps organize logs chronologically.
  • Efficient Batching: Log messages are intelligently batched to optimize API calls to CloudWatch Logs, respecting AWS limits for batch size (1MB) and event count (10,000 events).
  • Configurable Flush Interval: Control how frequently logs are sent to CloudWatch Logs via the flushInterval option (defaults to 3 seconds).
  • Automatic Message Truncation: If an individual log message exceeds CloudWatch's per-event size limit (approximately 1MB, minus overhead), it's automatically truncated with a [TRUNCATED] suffix to prevent errors.
  • Seamless Winston Integration: Designed as a standard Winston transport stream for easy integration into existing Winston logging setups.
  • Modern AWS SDK: Utilizes the modular AWS SDK v3 (@aws-sdk/client-cloudwatch-logs).
  • Asynchronous Operations: All logging and flushing operations are non-blocking, ensuring your application's performance is not impacted.

Installation

pnpm add @hirotoshioi/winston-cloudwatchlogs winston @aws-sdk/client-cloudwatch-logs
# or
yarn add @hirotoshioi/winston-cloudwatchlogs winston @aws-sdk/client-cloudwatch-logs
# or
npm install @hirotoshioi/winston-cloudwatchlogs winston @aws-sdk/client-cloudwatch-logs
# or
bun add @hirotoshioi/winston-cloudwatchlogs winston @aws-sdk/client-cloudwatch-logs

Usage

import winston from "winston";
import { CloudWatchLogsTransportStream } from "winston-cloudwatchlogs";
import { CloudWatchLogsClient } from "@aws-sdk/client-cloudwatch-logs";

async function main() {
  const logger = winston.createLogger({
    transports: [
      await CloudWatchLogsTransportStream.create({
        logGroupName: "your-log-group",
        logStreamNamePrefix: "your-app-prefix",
        cloudWatchLogsClientConfig: {
          region: "your-aws-region",
          credentials: {
            accessKeyId: "YOUR_AWS_ACCESS_KEY_ID",
            secretAccessKey: "YOUR_AWS_SECRET_ACCESS_KEY",
          },
        },
        flushInterval: 5000,
      }),
    ],
  });

  logger.info("Hello from winston-cloudwatchlogs!");
}

main().catch(console.error);

Considerations

  • IAM Permissions: Ensure the AWS identity (user or role) running your application has the necessary IAM permissions. Refer to the "AWS IAM Permissions" section below for details.
  • AWS Credentials Configuration: Credentials must be correctly configured for the AWS SDK. This can be done via the cloudWatchLogsClientConfig option, or through standard AWS mechanisms like environment variables (e.g., AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN), shared credential files (~/.aws/credentials), or IAM roles if running on AWS services (e.g., EC2, ECS, Lambda).
  • Log Group Existence: This transport assumes the specified logGroupName already exists. While the IAM permission logs:CreateLogGroup is recommended (see below), the transport itself does not explicitly create the log group if it's missing.

AWS IAM Permissions

To allow your application to send logs to CloudWatch, the AWS IAM role or user associated with your application needs the following permissions. You can attach this policy to the relevant IAM identity.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "logs:CreateLogStream",
        "logs:DescribeLogStreams",
        "logs:PutLogEvents"
      ],
      "Resource": ["*"]
    }
  ]
}

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

MIT