LogGroupTargetInputOptions

class aws_cdk.aws_events_targets.LogGroupTargetInputOptions(*, message=None, timestamp=None)

Bases: object

Options used when creating a target input template.

Parameters:
  • message (Any) – The value provided here will be used in the Log “message” field. This field must be a string. If an object is passed (e.g. JSON data) it will not throw an error, but the message that makes it to CloudWatch logs will be incorrect. This is a likely scenario if doing something like: EventField.fromPath(‘$.detail’) since in most cases the detail field contains JSON data. Default: EventField.detailType

  • timestamp (Any) – The timestamp that will appear in the CloudWatch Logs record. Default: EventField.time

ExampleMetadata:

infused

Example:

import aws_cdk.aws_logs as logs
# log_group: logs.LogGroup
# rule: events.Rule


rule.add_target(targets.CloudWatchLogGroup(log_group,
    log_event=targets.LogGroupTargetInput.from_object(
        timestamp=events.EventField.from_path("$.time"),
        message=events.EventField.from_path("$.detail-type")
    )
))

Attributes

message

The value provided here will be used in the Log “message” field.

This field must be a string. If an object is passed (e.g. JSON data) it will not throw an error, but the message that makes it to CloudWatch logs will be incorrect. This is a likely scenario if doing something like: EventField.fromPath(‘$.detail’) since in most cases the detail field contains JSON data.

Default:

EventField.detailType

timestamp

The timestamp that will appear in the CloudWatch Logs record.

Default:

EventField.time