The IAM permissions, API AccessKey, and SecretKey are all properly set up.
The result of putLogEvents is success and nextSequenceToken is also received correctly.
However, when checking the console, the logs are not visible even after more than 30 minutes have passed.
The following is a code example, and I would like feedback on whether there are any errors.
let credentialsProvider = AWSStaticCredentialsProvider(
accessKey: "ACCESS_KEY",
secretKey: "SECRET_KEY"
)
guard let configuration = AWSServiceConfiguration(
region: .USEast2,
credentialsProvider: credentialsProvider
) else { return }
AWSLogs.register(with: configuration, forKey: "default")
let defaultLogs = AWSLogs(forKey: "default")
let logGroupName = "MYGROUP"
let logStreamName = "MYSTREAM"
let logger = AWSDDLog.sharedInstance
logger.logLevel = .info
let logEvent = AWSLogsInputLogEvent()
logEvent?.message = "[MYDEBUG] TestTestTestTest"
logEvent?.timestamp = NSNumber(value: Int(Date.now.timeIntervalSince1970))
let logEvents = [logEvent!]
Task {
do {
let groupRequest = AWSLogsDescribeLogGroupsRequest()
let groupResponse = try await defaultLogs.describeLogGroups(groupRequest!)
let group = groupResponse.logGroups?[1].logGroupName
print("MYDEBUG: Group \(group)")
let streamRequest = AWSLogsDescribeLogStreamsRequest()
streamRequest?.logGroupName = group
let streamResponse = try await defaultLogs.describeLogStreams(streamRequest!)
print("MYDEBUG: Stream \(streamResponse.logStreams?.first?.logStreamName)")
let putLogEventsRequest = AWSLogsPutLogEventsRequest()
putLogEventsRequest?.logGroupName = group
putLogEventsRequest?.logStreamName = streamResponse.logStreams?.first?.logStreamName
putLogEventsRequest?.logEvents = logEvents
_ = try await defaultLogs.putLogEvents(putLogEventsRequest!)
} catch {
print("[MYDEBUG] \(error)")
}
}
Thank you
Region checked (actually AP Northeast2 in my code).
It is said that the log transmission was also successful.
After "putLogEvents", "nextSequenceToken" was successfully transmitted in response
It's a self-answer.
TimeStamp is invalid. It works well if you convert it to TimeStamp instead of TimeInterval.