The code examples in this directory demonstrate how to work with Amazon CloudWatch using the AWS SDK for JavaScript (v3).
Amazon CloudWatch provides a reliable, scalable, and flexible monitoring solution that you can start using within minutes. You no longer need to set up, manage, and scale your own monitoring systems and infrastructure.
- Delete CloudWatch alarms
- Describe CloudWatch alarms
- Disable CloudWatch alarm actions
- Enable CloudWatch alarm actions
- List CloudWatch metrics
- Put CloudWatch metric alarms
- Put CloudWatch metric data
Note: All code examples are written in ECMAscript 6 (ES6). For guidelines on converting to CommonJS, see JavaScript ES6/CommonJS syntax.
- As an AWS best practice, grant this code least privilege, or only the permissions required to perform a task. For more information, see Grant least privilege in the AWS Identity and Access Management User Guide.
- This code has not been tested in all AWS Regions. Some AWS services are available only in specific AWS Regions. For more information, see the AWS Regional Services List on the AWS website.
- Running this code might result in charges to your AWS account.
- An AWS account. To create an account, see How do I create and activate a new AWS account on the AWS Premium Support website.
- AWS credentials. For details, see Setting credentials in Node.js in the AWS SDK for Javascript (v3) Developer Guide.
-
Clone the AWS Code Samples repo to your local environment. See the Github documentation for instructions.
-
Install the dependencies listed in the package.json.
Note: These dependencies include the client modules for the AWS services that this example requires, which is @aws-sdk/client-cloudwatch.
npm install node -g
cd javascriptv3/example_code/cloudwatch
npm install
-
In your text editor, update user variables specified in the
Inputssection of the sample file. -
Run sample code:
cd src
node [example name].js
Unit tests<./tests>_ are provided for most examples, using the Jest <https://jestjs.io/>_ framework.
For example, to run tests on the cloudwatch folder, enter the following sequence of commands at the command prompt:
npm install node -g
cd javascriptv3/example_code/cloudwatch/tests
npm install
npm test