putLogEvents method
Uploads a batch of log events to the specified log stream. The batch of events must satisfy the following constraints:
- The maximum batch size is 1,048,576 bytes. This size is calculated as the sum of all event messages in UTF-8, plus 26 bytes for each log event.
- Events more than 2 hours in the future are rejected while processing remaining valid events.
- Events older than 14 days or preceding the log group's retention period are rejected while processing remaining valid events.
-
The log events in the batch must be in chronological order by their
timestamp. The timestamp is the time that the event occurred, expressed as
the number of milliseconds after
Jan 1, 1970 00:00:00 UTC. (In Amazon Web Services Tools for PowerShell and the Amazon Web Services SDK for .NET, the timestamp is specified in .NET format:yyyy-mm-ddThh:mm:ss. For example,2017-09-15T13:45:30.) - A batch of log events in a single request must be in a chronological order. Otherwise, the operation fails.
- Each log event can be no larger than 1 MB.
- The maximum number of log events in a batch is 10,000.
- For valid events (within 14 days in the past to 2 hours in future), the time span in a single batch cannot exceed 24 hours. Otherwise, the operation fails.
PutLogEvents returns
"UnrecognizedClientException" the most likely cause is a non-valid Amazon
Web Services access key ID or secret key.
May throw DataAlreadyAcceptedException.
May throw InvalidParameterException.
May throw InvalidSequenceTokenException.
May throw ResourceNotFoundException.
May throw ServiceUnavailableException.
May throw UnrecognizedClientException.
Parameter logEvents :
The log events.
Parameter logGroupName :
The name of the log group.
Parameter logStreamName :
The name of the log stream.
Parameter entity :
The entity associated with the log events.
Parameter sequenceToken :
The sequence token obtained from the response of the previous
PutLogEvents call.
Implementation
Future<PutLogEventsResponse> putLogEvents({
required List<InputLogEvent> logEvents,
required String logGroupName,
required String logStreamName,
Entity? entity,
String? sequenceToken,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Logs_20140328.PutLogEvents'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'logEvents': logEvents,
'logGroupName': logGroupName,
'logStreamName': logStreamName,
if (entity != null) 'entity': entity,
if (sequenceToken != null) 'sequenceToken': sequenceToken,
},
);
return PutLogEventsResponse.fromJson(jsonResponse.body);
}