aws-cdk-lib.aws_events_targets.LogGroupTargetInputOptions

interface LogGroupTargetInputOptions

LanguageType name
.NETAmazon.CDK.AWS.Events.Targets.LogGroupTargetInputOptions
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awseventstargets#LogGroupTargetInputOptions
Javasoftware.amazon.awscdk.services.events.targets.LogGroupTargetInputOptions
Pythonaws_cdk.aws_events_targets.LogGroupTargetInputOptions
TypeScript (source)aws-cdk-lib » aws_events_targets » LogGroupTargetInputOptions

Options used when creating a target input template.

Example

import * as logs from 'aws-cdk-lib/aws-logs';
declare const logGroup: logs.LogGroup;
declare const rule: events.Rule;

rule.addTarget(new targets.CloudWatchLogGroup(logGroup, {
  logEvent: targets.LogGroupTargetInput.fromObject({
    timestamp: events.EventField.fromPath('$.time'),
    message: events.EventField.fromPath('$.detail-type'),
  }),
}));

Properties

NameTypeDescription
message?anyThe value provided here will be used in the Log "message" field.
timestamp?anyThe timestamp that will appear in the CloudWatch Logs record.

message?

Type: any (optional, default: EventField.detailType)

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.


timestamp?

Type: any (optional, default: EventField.time)

The timestamp that will appear in the CloudWatch Logs record.