LogGroupProps Struct
Customize the CloudWatch LogGroup Event Target.
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({
message: JSON.stringify({
CustomField: 'CustomValue',
}),
}),
}));
python
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(
message=JSON.stringify({
"CustomField": "CustomValue"
})
)
))
java
import software.amazon.awscdk.services.logs.*;
LogGroup logGroup;
Rule rule;
rule.addTarget(CloudWatchLogGroup.Builder.create(logGroup)
.logEvent(LogGroupTargetInput.fromObjectV2(LogGroupTargetInputOptions.builder()
.message(JSON.stringify(Map.of(
"CustomField", "CustomValue")))
.build()))
.build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.Logs;
LogGroup logGroup;
Rule rule;
rule.AddTarget(new CloudWatchLogGroup(logGroup, new LogGroupProps {
LogEvent = LogGroupTargetInput.FromObjectV2(new LogGroupTargetInputOptions {
Message = JSON.Stringify(new Dictionary<string, string> {
{ "CustomField", "CustomValue" }
})
})
}));
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import logs "github.com/aws/aws-cdk-go/awscdk"
var logGroup LogGroup
var rule Rule
rule.AddTarget(targets.NewCloudWatchLogGroup(logGroup, &LogGroupProps{
LogEvent: targets.LogGroupTargetInput_FromObjectV2(&LogGroupTargetInputOptions{
Message: jSON.stringify(map[string]*string{
"CustomField": jsii.String("CustomValue"),
}),
}),
}))
Properties
deadLetterQueueoptionalIQueuedead_letter_queueoptionalIQueuedeadLetterQueueoptionalIQueueDeadLetterQueueoptionalIQueueDeadLetterQueueoptionalIQueue#The SQS queue to be used as deadLetterQueue. Check out the [considerations for using a dead-letter queue](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html#dlq-considerations).
Default: no dead-letter queue
notes
The events not successfully delivered are automatically retried for a specified period of time, depending on the retry policy of the target. If an event is not delivered before all retry attempts are exhausted, it will be sent to the dead letter queue.
eventoptionalRuleTargetInputeventoptionalRuleTargetInputeventoptionalRuleTargetInputEventoptionalRuleTargetInputEventoptionalRuleTargetInputdeprecated#use logEvent instead
Default: the entire EventBridge event
This will be the event logged into the CloudWatch LogGroup
installLatestAwsSdkoptionalbooleaninstall_latest_aws_sdkoptionalboolinstallLatestAwsSdkoptionalBooleanInstallLatestAwsSdkoptionalboolInstallLatestAwsSdkoptional*bool#Whether the custom resource created wll default to install latest AWS SDK.
Default: install latest AWS SDK
logEventoptionalLogGroupTargetInputlog_eventoptionalLogGroupTargetInputlogEventoptionalLogGroupTargetInputLogEventoptionalLogGroupTargetInputLogEventoptionalLogGroupTargetInput#The event to send to the CloudWatch LogGroup.
Default: the entire EventBridge event
This will be the event logged into the CloudWatch LogGroup
maxEventAgeoptionalDurationmax_event_ageoptionalDurationmaxEventAgeoptionalDurationMaxEventAgeoptionalDurationMaxEventAgeoptionalDuration= Duration.hours(24)#The maximum age of a request that Lambda sends to a function for processing.
Minimum value of 60. Maximum value of 86400.
retryAttemptsoptionalnumberretry_attemptsoptionalint | floatretryAttemptsoptionalNumberRetryAttemptsoptionaldoubleRetryAttemptsoptional*float64= 185#The maximum number of times to retry when the function returns an error.
Minimum value of 0. Maximum value of 185.