This is the new AWS CloudFormation Template Reference Guide. Please update your bookmarks and links. For help getting started with CloudFormation, see the AWS CloudFormation User Guide.
AWS::Logs::MetricFilter
The AWS::Logs::MetricFilter
resource specifies a metric filter that
describes how CloudWatch Logs extracts information from logs and transforms it into
Amazon CloudWatch metrics. If you have multiple metric filters that are associated with
a log group, all the filters are applied to the log streams in that group.
The maximum number of metric filters that can be associated with a log group is 100.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::Logs::MetricFilter", "Properties" : { "ApplyOnTransformedLogs" :
Boolean
, "EmitSystemFieldDimensions" :[ String, ... ]
, "FieldSelectionCriteria" :String
, "FilterName" :String
, "FilterPattern" :String
, "LogGroupName" :String
, "MetricTransformations" :[ MetricTransformation, ... ]
} }
YAML
Type: AWS::Logs::MetricFilter Properties: ApplyOnTransformedLogs:
Boolean
EmitSystemFieldDimensions:- String
FieldSelectionCriteria:String
FilterName:String
FilterPattern:String
LogGroupName:String
MetricTransformations:- MetricTransformation
Properties
ApplyOnTransformedLogs
-
This parameter is valid only for log groups that have an active log transformer. For more information about log transformers, see PutTransformer.
If this value is
true
, the metric filter is applied on the transformed version of the log events instead of the original ingested log events.Required: No
Type: Boolean
Update requires: No interruption
EmitSystemFieldDimensions
-
The list of system fields that are emitted as additional dimensions in the generated metrics. Returns the
emitSystemFieldDimensions
value if it was specified when the metric filter was created.Required: No
Type: Array of String
Update requires: No interruption
FieldSelectionCriteria
-
The filter expression that specifies which log events are processed by this metric filter based on system fields. Returns the
fieldSelectionCriteria
value if it was specified when the metric filter was created.Required: No
Type: String
Minimum:
0
Maximum:
2000
Update requires: No interruption
FilterName
-
The name of the metric filter.
Required: No
Type: String
Pattern:
^[^:*]{1,512}
Minimum:
1
Maximum:
512
Update requires: Replacement
FilterPattern
-
A filter pattern for extracting metric data out of ingested log events. For more information, see Filter and Pattern Syntax.
Required: Yes
Type: String
Maximum:
1024
Update requires: No interruption
LogGroupName
-
The name of an existing log group that you want to associate with this metric filter.
Required: Yes
Type: String
Pattern:
^[.\-_/#A-Za-z0-9]{1,512}
Minimum:
1
Maximum:
512
Update requires: Replacement
MetricTransformations
-
The metric transformations.
Required: Yes
Type: Array of MetricTransformation
Minimum:
1
Maximum:
1
Update requires: No interruption
Examples
Create a Metric Filter
The following example sends a value of 1
to the
404Count
metric whenever the status code field includes a
404
value.
JSON
"404MetricFilter": { "Type": "AWS::Logs::MetricFilter", "Properties": { "LogGroupName": { "Ref": "myLogGroup" }, "FilterPattern": "[ip, identity, user_id, timestamp, request, status_code = 404, size]", "MetricTransformations": [ { "MetricValue": "1", "MetricNamespace": "WebServer/404s", "MetricName": "404Count" } ] } }
YAML
404MetricFilter: Type: AWS::Logs::MetricFilter Properties: LogGroupName: Ref: "myLogGroup" FilterPattern: "[ip, identity, user_id, timestamp, request, status_code = 404, size]" MetricTransformations: - MetricValue: "1" MetricNamespace: "WebServer/404s" MetricName: "404Count"