There are more AWS SDK examples available in the AWS Doc SDK Examples
CloudWatch Logs examples using SDK for JavaScript (v2)
The following code examples show you how to perform actions and implement common scenarios by using the AWS SDK for JavaScript (v2) with CloudWatch Logs.
Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.
Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.
Topics
Actions
The following code example shows how to use DeleteSubscriptionFilter
.
- SDK for JavaScript (v2)
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. // Load the AWS SDK for Node.js var AWS = require("aws-sdk"); // Set the region AWS.config.update({ region: "REGION" }); // Create the CloudWatchLogs service object var cwl = new AWS.CloudWatchLogs({ apiVersion: "2014-03-28" }); var params = { filterName: "FILTER", logGroupName: "LOG_GROUP", }; cwl.deleteSubscriptionFilter(params, function (err, data) { if (err) { console.log("Error", err); } else { console.log("Success", data); } });
-
For more information, see AWS SDK for JavaScript Developer Guide.
-
For API details, see DeleteSubscriptionFilter in AWS SDK for JavaScript API Reference.
-
The following code example shows how to use DescribeSubscriptionFilters
.
- SDK for JavaScript (v2)
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. // Load the AWS SDK for Node.js var AWS = require("aws-sdk"); // Set the region AWS.config.update({ region: "REGION" }); // Create the CloudWatchLogs service object var cwl = new AWS.CloudWatchLogs({ apiVersion: "2014-03-28" }); var params = { logGroupName: "GROUP_NAME", limit: 5, }; cwl.describeSubscriptionFilters(params, function (err, data) { if (err) { console.log("Error", err); } else { console.log("Success", data.subscriptionFilters); } });
-
For more information, see AWS SDK for JavaScript Developer Guide.
-
For API details, see DescribeSubscriptionFilters in AWS SDK for JavaScript API Reference.
-
The following code example shows how to use PutSubscriptionFilter
.
- SDK for JavaScript (v2)
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. // Load the AWS SDK for Node.js var AWS = require("aws-sdk"); // Set the region AWS.config.update({ region: "REGION" }); // Create the CloudWatchLogs service object var cwl = new AWS.CloudWatchLogs({ apiVersion: "2014-03-28" }); var params = { destinationArn: "LAMBDA_FUNCTION_ARN", filterName: "FILTER_NAME", filterPattern: "ERROR", logGroupName: "LOG_GROUP", }; cwl.putSubscriptionFilter(params, function (err, data) { if (err) { console.log("Error", err); } else { console.log("Success", data); } });
-
For more information, see AWS SDK for JavaScript Developer Guide.
-
For API details, see PutSubscriptionFilter in AWS SDK for JavaScript API Reference.
-