

# Quick Start: Use Amazon CloudFormation to get started with CloudWatch Logs
<a name="QuickStartCloudFormation"></a>

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](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/quickref-cloudwatchlogs.html) in the *Amazon CloudFormation User Guide*. For more information about getting started, see [Getting Started with Amazon CloudFormation](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/GettingStarted.html) in the *Amazon CloudFormation User Guide*.