The code examples in this directory demonstrate how to work with Amazon CloudWatch Logs using the AWS SDK for JavaScript (v3).
You can use Amazon CloudWatch Logs to monitor, store, and access your log files from Amazon Elastic Compute Cloud (Amazon EC2) instances, AWS CloudTrail, Route 53, and other sources.
- Running this code might result in charges to your AWS account.
- Running the tests might result in charges to your AWS account.
- We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see Grant least privilege.
- This code is not tested in every AWS Region. For more information, see AWS Regional Services.
Code excerpts that show you how to call individual service functions.
- Create a log group
- Create a subscription filter
- Delete a log group
- Delete a subscription filter
- Describe log groups
- Describe existing subscription filters
Note: All code examples are written in ECMAscript 6 (ES6). For guidelines on converting to CommonJS, see JavaScript ES6/CommonJS syntax.
- Set up AWS SDK for JavaScript
- Run
yarn
to install dependencies.
Run a single action
- Run
node ./actions/<fileName>
. OR - Import
./actions/fileName
into another module.
- Run
yarn
. - Run
yarn test
.
- Run
yarn
. - Run
yarn integration-test
.
- Amazon CloudWatch Logs User Guide
- Amazon CloudWatch Logs API Reference
- CloudWatch Logs Client - AWS SDK for JavaScript (v3)
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0