Quick Start: Use Amazon CloudFormation to get started with CloudWatch Logs - Amazon CloudWatch Logs
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Quick Start: Use Amazon CloudFormation to get started with CloudWatch Logs

Amazon CloudFormation enables you to describe and provision your Amazon resources in JSON format. The advantages of this method include being able to manage a collection of Amazon resources as a single unit, and easily replicating your Amazon resources across Regions.

When you provision Amazon using Amazon CloudFormation, you create templates that describe the Amazon resources to use. The following example is a template snippet that creates a log group and a metric filter that counts 404 occurrences and sends this count to the log group.

"WebServerLogGroup": { "Type": "AWS::Logs::LogGroup", "Properties": { "RetentionInDays": 7 } }, "404MetricFilter": { "Type": "AWS::Logs::MetricFilter", "Properties": { "LogGroupName": { "Ref": "WebServerLogGroup" }, "FilterPattern": "[ip, identity, user_id, timestamp, request, status_code = 404, size, ...]", "MetricTransformations": [ { "MetricValue": "1", "MetricNamespace": "test/404s", "MetricName": "test404Count" } ] } }

This is a basic example. You can set up much richer CloudWatch Logs deployments using Amazon CloudFormation. For more information about template examples, see Amazon CloudWatch Logs Template Snippets in the Amazon CloudFormation User Guide. For more information about getting started, see Getting Started with Amazon CloudFormation in the Amazon CloudFormation User Guide.