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 🙏

© 2024 – Pkg Stats / Ryan Hefner

aws-logs-comptroller

v0.1.5

Published

Set Log Retention and prune orphaned LogGroups on a schedule using Step Functions service integrations and intrinsic functions.

Downloads

62

Readme

AWS Logs Comptroller

:warning: This construct is designed to delete logs and log groups! Use at your own risk! :warning:

AWS Logs Comptroller is a CDK Construct that can be used to set CloudWatch log retention as well as prune orphaned LogGroups. AWS Logs Comptroller is written entirely using Step Functions and ASL. It makes service integration calls and uses intrinsic functions in lieu of a custom compute layer such as a Lambda Function.

AWS Logs Comptroller can handle a large number of LogGroups without failure or timeout due to its architecture and has been tested with thousands of LogGroups. It makes many API calls to CloudWatch (to fetch, update and delete LogGroups) and to Lambda (to identify whether or not the LogGroup is attached to an existing Lambda Function) and may cause throttling to other processes that utilize these APIs.

const app = new App();
const stack = new Stack(app);

new AwsLogsComptroller(stack, 'LogsComptroller');

Log Retention

AWS Logs Comptroller will apply a retention period to any LogGroups that lack retention. The default for this is seven days but this can be overriden by passing in the retentionDays prop.

const app = new App();
const stack = new Stack(app);

new AwsLogsComptroller(stack, 'LogsComptroller', { retentionDays: RetentionDays.ONE_DAY });

Removing 'orphaned' Lambda LogGroups

Lambda automatically creates LogGroups when a function is called. If the function is later deleted, the LogGroup remains. AWS Logs Comptroller will remove any LogGroups that don't have existing Lambda Functions by parsing the name of the function from the LogGroup and attempting a GetFunction API call. If that call returns a 404, the LogGroup will be deleted.

Scheduling

AWS Logs Comptroller can be scheduled using an EventBridge rule. By default, it'll use the default eventbus and run once daily.

const app = new App();
const stack = new Stack(app);

new AwsLogsComptroller(stack, 'LogsComptroller', { schedule: true });

The schedule prop can also accept a cron expression.

const app = new App();
const stack = new Stack(app);

new AwsLogsComptroller(stack, 'LogsComptroller', { schedule: Schedule.cron({ day: '1', hour: '4', minute: '0', }) });

Additionally the schedule Rule can be assigned to a custom EventBus.

const app = new App();
const stack = new Stack(app);

const bus = new EventBus(stack, 'MyEventBus');
new AwsLogsComptroller(stack, 'LogsComptroller', { eventBus: bus, schedule: true });