A filter that extracts information from CloudWatch Logs and emits to CloudWatch Metrics.
import { MetricFilter } from 'aws-cdk-lib/aws-logs';Or use the module namespace:
import * as logs from 'aws-cdk-lib/aws-logs';
// logs.MetricFilterConfiguration passed to the constructor as MetricFilterProps.
logGroupRequiredILogGroupRefThe log group to create the filter on.
MetricFilterOptionsfilterPatternRequiredinherited from MetricFilterOptionsIFilterPatternPattern to search for log events.
metricNameRequiredinherited from MetricFilterOptionsstringThe name of the metric to emit.
metricNamespaceRequiredinherited from MetricFilterOptionsstringThe namespace of the metric to emit.
applyOnTransformedLogsOptionalinherited from MetricFilterOptionsbooleanWhether the metric filter is applied on the tranformed logs. This parameter is valid only for log groups that have an active log transformer. 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.
Default: - false
defaultValueOptionalinherited from MetricFilterOptionsnumberThe value to emit if the pattern does not match a particular event.
Default: No metric emitted.
dimensionsOptionalinherited from MetricFilterOptions{ [key: string]: string }The fields to use as dimensions for the metric. One metric filter can include as many as three dimensions.
Default: - No dimensions attached to metrics.
filterNameOptionalinherited from MetricFilterOptionsstringThe name of the metric filter.
Default: - Cloudformation generated name.
metricValueOptionalinherited from MetricFilterOptionsstringThe value to emit for the metric. Can either be a literal number (typically "1"), or the name of a field in the structure to take the value from the matched event. If you are using a field value, the field value must have been matched using the pattern. If you want to specify a field from a matched JSON structure, use '$.fieldName', and make sure the field is in the pattern (if only as '$.fieldName = *'). If you want to specify a field from a matched space-delimited structure, use '$fieldName'.
Default: "1"
unitOptionalinherited from MetricFilterOptionsUnitThe unit to assign to the metric.
Default: - No unit attached to metrics.
Our bi-weekly newsletter teaches hands-on AWS fundamentals. No certification fluff - just practical knowledge.
Subscribe to Newsletteraws-logs