2021-05-14 12:33:40 +01:00
# Amazon Cloudwatch JavaScript SDK v3 code examples
Amazon Cloudwatch enables you to collect, access, and correlate this data on a single platform from across all your AWS resources, applications, and services.
2020-10-02 16:34:29 +01:00
2021-05-14 12:33:40 +01:00
## Code examples
This is a workspace where you can find the following AWS SDK for JavaScript version 3 (v3) Amazon Cloudwatch examples:
2020-09-30 15:40:42 +01:00
2021-06-01 11:18:57 +01:00
- [Delete CloudWatch alarms ](src/deleteAlarms.js )
- [Describe CloudWatch alarms ](src/describeAlarms.js )
2021-06-01 15:48:05 +01:00
- [Disable CloudWatch alarm actions ](src/disableAlarmActions.js )
2021-06-01 11:18:57 +01:00
- [Enable CloudWatch alarm actions ](src/enableAlarmActions.js )
- [List CloudWatch metrics ](src/listMetrics.js )
- [Put CloudWatch metric alarms ](src/putMetricAlarm.js )
- [Put CloudWatch metric data ](src/putMetricData.js )
2020-12-14 13:03:47 +00:00
2021-05-14 12:33:40 +01:00
**Note ** : All code examples are written in ECMAscript 6 (ES6). For guidelines on converting to CommonJS, see
[JavaScript ES6/CommonJS syntax ](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/sdk-examples-javascript-syntax.html ).
2020-09-30 15:40:42 +01:00
2021-05-14 12:33:40 +01:00
## Getting started
2020-09-30 15:40:42 +01:00
2020-10-05 13:51:17 +01:00
1. Clone the [AWS Code Samples repo ](https://github.com/awsdocs/aws-doc-sdk-examples ) to your local environment.
See [the Github documentation ](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository ) for
2020-09-30 15:40:42 +01:00
instructions.
2. Install the dependencies listed in the package.json.
**Note ** : These dependencies include the client modules for the AWS services that this example requires,
which are the * @aws-sdk/client-cloudwatch * , * @aws-sdk/client-cloudwatch-events * , and * @aws-sdk/client-cloudwatch-logs * .
```
2021-05-14 12:33:40 +01:00
npm install node -g
2020-09-30 15:40:42 +01:00
cd javascriptv3/example_code/cloudwatch
npm install
```
2021-05-14 12:33:40 +01:00
3. In your text editor, update user variables specified in the ```Inputs` `` section of the sample file.
2020-09-30 15:40:42 +01:00
2021-05-14 12:33:40 +01:00
4. Run sample code:
2020-09-30 15:40:42 +01:00
```
cd src
2021-05-14 12:33:40 +01:00
node [example name].js
2020-09-30 15:40:42 +01:00
```
2021-05-14 12:33:40 +01:00
## Resources
- [AWS SDK for JavaScript v3 repo ](https://github.com/aws/aws-sdk-js-v3 ) .
- [AWS SDK for JavaScript v3 Developer Guide ](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/cloudwatch-examples.html )
- [AWS SDK for JavaScript v3 API Reference Guide - Amazon Cloudwatch client module ](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-cloudwatch/index.html )
- [AWS SDK for JavaScript v3 API Reference Guide - Amazon Cloudwatch Events client module ](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-cloudwatch-events/index.html )
- [AWS SDK for JavaScript v3 API Reference Guide - Amazon Cloudwatch Logs client module ](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-cloudwatch-logs/index.html )
2020-09-30 15:40:42 +01:00