SubscriptionFilterProps

class aws_cdk.aws_logs.SubscriptionFilterProps(*, destination, filter_pattern, distribution=None, filter_name=None, log_group)

Bases: SubscriptionFilterOptions

Properties for a SubscriptionFilter.

Parameters:
  • destination (ILogSubscriptionDestination) – The destination to send the filtered events to. For example, a Kinesis stream or a Lambda function.

  • filter_pattern (IFilterPattern) – Log events matching this pattern will be sent to the destination.

  • distribution (Optional[Distribution]) – The method used to distribute log data to the destination. This property can only be used with KinesisDestination. Default: Distribution.BY_LOG_STREAM

  • filter_name (Optional[str]) – The name of the subscription filter. Default: Automatically generated

  • log_group (ILogGroup) – The log group to create the subscription on.

ExampleMetadata:

infused

Example:

import aws_cdk.aws_logs_destinations as destinations

# fn: lambda.Function
# log_group: logs.LogGroup


logs.SubscriptionFilter(self, "Subscription",
    log_group=log_group,
    destination=destinations.LambdaDestination(fn),
    filter_pattern=logs.FilterPattern.all_terms("ERROR", "MainThread"),
    filter_name="ErrorInMainThread"
)

Attributes

destination

The destination to send the filtered events to.

For example, a Kinesis stream or a Lambda function.

distribution

The method used to distribute log data to the destination.

This property can only be used with KinesisDestination.

Default:

Distribution.BY_LOG_STREAM

filter_name

The name of the subscription filter.

Default:

Automatically generated

filter_pattern

Log events matching this pattern will be sent to the destination.

log_group

The log group to create the subscription on.