LogGroupTargetInput

class aws_cdk.aws_events_targets.LogGroupTargetInput

Bases: RuleTargetInput

The input to send to the CloudWatch LogGroup target.

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_v2(
        timestamp=events.EventField.from_path("$.time"),
        message=events.EventField.from_path("$.detail-type")
    )
))

Methods

abstractmethod bind(rule)

Return the input properties for this input object.

Parameters:

rule (IRuleRef)

Return type:

RuleTargetInputProperties

Static Methods

classmethod from_event_path(path)

Take the event target input from a path in the event JSON.

Parameters:

path (str)

Return type:

RuleTargetInput

classmethod from_multiline_text(text)

Pass text to the event target, splitting on newlines.

This is only useful when passing to a target that does not take a single argument.

May contain strings returned by EventField.from() to substitute in parts of the matched event.

Parameters:

text (str)

Return type:

RuleTargetInput

classmethod from_object(options)

(deprecated) Pass a JSON object to the log group event target.

May contain strings returned by EventField.from() to substitute in parts of the matched event.

Parameters:

options (Any)

Deprecated:

use fromObjectV2

Stability:

deprecated

Return type:

RuleTargetInput

classmethod from_object_v2(*, message=None, timestamp=None)

Pass a JSON object to the log group event target.

May contain strings returned by EventField.from() to substitute in parts of the matched event.

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

Return type:

LogGroupTargetInput

classmethod from_text(text)

Pass text to the event target.

May contain strings returned by EventField.from() to substitute in parts of the matched event.

The Rule Target input value will be a single string: the string you pass here. Do not use this method to pass a complex value like a JSON object to a Rule Target. Use RuleTargetInput.fromObject() instead.

Parameters:

text (str)

Return type:

RuleTargetInput