AWS CloudWatch
This forwarder is used to send a log record to an AWS CloudWatch Logs stream.
Data Model
note
- The secret access key and the session token are NOT encrypted in the database.
- The log group and the log stream must exist prior to sending records, they are not created by the forwarder.
Behavior
client := cloudwatchlogs.New(cloudwatchlogs.Options{
AppID: appID,
BaseEndpoint: &endpoint,
Credentials: credentials.NewStaticCredentialsProvider(
accessKeyID,
secretAccessKey,
sessionToken,
),
Region: region,
})
message, err := json.Marshal(logRecord.Fields)
// ...
_, err = client.PutLogEvents(ctx, &cloudwatchlogs.PutLogEventsInput{
LogEvents: []types.InputLogEvent{
{
Message: new(string(message)),
Timestamp: new(logRecord.Timestamp.UnixMilli()),
},
},
LogGroupName: &group,
LogStreamName: &stream,
})
// ...