Resource: awsCloudwatchLogMetricFilter
Provides a CloudWatch Log Metric Filter resource.
Example Usage
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsCloudwatchLogGroupDada = new aws.cloudwatchLogGroup.CloudwatchLogGroup(
this,
"dada",
{
name: "MyApp/access.log",
}
);
new aws.cloudwatchLogMetricFilter.CloudwatchLogMetricFilter(this, "yada", {
logGroupName: awsCloudwatchLogGroupDada.name,
metricTransformation: {
name: "EventCount",
namespace: "YourNamespace",
value: "1",
},
name: "MyAppAccessCount",
pattern: "",
});
Argument Reference
The following arguments are supported:
name
- (Required) A name for the metric filter.pattern
- (Required) A valid CloudWatch Logs filter pattern for extracting metric data out of ingested log events.logGroupName
- (Required) The name of the log group to associate the metric filter with.metricTransformation
- (Required) A block defining collection of information needed to define how metric data gets emitted. See below.
The metricTransformation
block supports the following arguments:
name
- (Required) The name of the CloudWatch metric to which the monitored log information should be published (e.g.,errorCount
)namespace
- (Required) The destination namespace of the CloudWatch metric.value
- (Required) What to publish to the metric. For example, if you're counting the occurrences of a particular term like "Error", the value will be "1" for each occurrence. If you're counting the bytes transferred the published value will be the value in the log event.defaultValue
- (Optional) The value to emit when a filter pattern does not match a log event. Conflicts withdimensions
.dimensions
- (Optional) Map of fields to use as dimensions for the metric. Up to 3 dimensions are allowed. Conflicts withdefaultValue
.unit
- (Optional) The unit to assign to the metric. If you omit this, the unit is set asnone
.
Attributes Reference
In addition to all arguments above, the following attributes are exported:
id
- The name of the metric filter.
Import
CloudWatch Log Metric Filter can be imported using the logGroupName:name
, e.g.,