Socket
Socket
Sign inDemoInstall

@aws-cdk/aws-logs

Package Overview
Dependencies
Maintainers
5
Versions
288
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-cdk/aws-logs

The CDK Construct Library for AWS::Logs


Version published
Weekly downloads
168K
increased by31.79%
Maintainers
5
Weekly downloads
 
Created

What is @aws-cdk/aws-logs?

@aws-cdk/aws-logs is an AWS Cloud Development Kit (CDK) library that allows you to define and manage AWS CloudWatch Logs resources using code. It provides a high-level, object-oriented abstraction to create and manage log groups, log streams, and metric filters, among other CloudWatch Logs features.

What are @aws-cdk/aws-logs's main functionalities?

Create a Log Group

This code sample demonstrates how to create a new CloudWatch Log Group with a specified retention period using the @aws-cdk/aws-logs package.

const logs = require('@aws-cdk/aws-logs');
const cdk = require('@aws-cdk/core');

const app = new cdk.App();
const stack = new cdk.Stack(app, 'MyStack');

new logs.LogGroup(stack, 'MyLogGroup', {
  logGroupName: '/aws/my-log-group',
  retention: logs.RetentionDays.ONE_WEEK
});

app.synth();

Create a Log Stream

This code sample demonstrates how to create a new CloudWatch Log Stream within an existing Log Group using the @aws-cdk/aws-logs package.

const logs = require('@aws-cdk/aws-logs');
const cdk = require('@aws-cdk/core');

const app = new cdk.App();
const stack = new cdk.Stack(app, 'MyStack');

const logGroup = new logs.LogGroup(stack, 'MyLogGroup', {
  logGroupName: '/aws/my-log-group',
  retention: logs.RetentionDays.ONE_WEEK
});

new logs.LogStream(stack, 'MyLogStream', {
  logGroup: logGroup,
  logStreamName: 'my-log-stream'
});

app.synth();

Create a Metric Filter

This code sample demonstrates how to create a Metric Filter for a CloudWatch Log Group that filters log events containing the term 'ERROR' and increments a custom metric in CloudWatch.

const logs = require('@aws-cdk/aws-logs');
const cdk = require('@aws-cdk/core');

const app = new cdk.App();
const stack = new cdk.Stack(app, 'MyStack');

const logGroup = new logs.LogGroup(stack, 'MyLogGroup', {
  logGroupName: '/aws/my-log-group',
  retention: logs.RetentionDays.ONE_WEEK
});

new logs.MetricFilter(stack, 'MyMetricFilter', {
  logGroup: logGroup,
  metricNamespace: 'MyNamespace',
  metricName: 'MyMetric',
  filterPattern: logs.FilterPattern.allTerms('ERROR'),
  metricValue: '1'
});

app.synth();

Other packages similar to @aws-cdk/aws-logs

Keywords

FAQs

Package last updated on 19 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc