Skip to content
v2.274.0

LogGroupTargetInputOptions Struct ​

Options used when creating a target input template.

Example ​

ts
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.fromObjectV2({
    timestamp: events.EventField.fromPath('$.time'),
    message: events.EventField.fromPath('$.detail-type'),
  }),
}));

Properties ​

messageanymessageAnymessageObjectMessageobjectMessageinterface{}= EventField.detailType#
The value provided here will be used in the Log "message" field.
notes

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.

timestampanytimestampAnytimestampObjectTimestampobjectTimestampinterface{}= EventField.time#
The timestamp that will appear in the CloudWatch Logs record.