Uploads a batch of log events to the specified log stream.
The sequence token is now ignored in PutLogEvents actions. PutLogEvents actions are always accepted and never return InvalidSequenceTokenException or DataAlreadyAcceptedException even if the sequence token is not valid. You can use parallel PutLogEvents actions on the same 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.
The quota of five requests per second per log stream has been removed. Instead, PutLogEvents actions are throttled based on a per-second per-account quota. You can request an increase to the per-second throttling quota by using the Service Quotas service.
If a call to PutLogEvents returns "UnrecognizedClientException" the most likely cause is a non-valid Amazon Web Services access key ID or secret key.
Parameters:
-
log_group_name
(LogGroupName)
–
The name of the log group.
-
log_stream_name
(LogStreamName)
–
The name of the log stream.
-
log_events
(InputLogEvents)
–
-
sequence_token
(Optional[SequenceToken], default:
None
)
–
The sequence token obtained from the response of the previous PutLogEvents call.
The sequenceToken parameter is now ignored in PutLogEvents actions. PutLogEvents actions are now accepted and never return InvalidSequenceTokenException or DataAlreadyAcceptedException even if the sequence token is not valid.
-
entity
(Optional[Entity], default:
None
)
–
The entity associated with the log events.
Raises:
-
DataAlreadyAcceptedException
–
The event was already logged.
PutLogEvents actions are now always accepted and never return DataAlreadyAcceptedException regardless of whether a given batch of log events has already been accepted.
-
InvalidParameterException
–
A parameter is specified incorrectly.
-
InvalidSequenceTokenException
–
The sequence token is not valid. You can get the correct sequence token in the expectedSequenceToken field in the InvalidSequenceTokenException message.
PutLogEvents actions are now always accepted and never return InvalidSequenceTokenException regardless of receiving an invalid sequence token.
-
ResourceNotFoundException
–
The specified resource does not exist.
-
ServiceUnavailableException
–
The service cannot complete the request.
-
UnrecognizedClientException
–
The most likely cause is an Amazon Web Services access key ID or secret key that's not valid.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_cloudwatch_logs/_services/cloud_watch_logs.py
| def put_log_events(
self,
log_group_name: "capo_cloudwatch_logs.types.log_group_name.LogGroupName",
log_stream_name: "capo_cloudwatch_logs.types.log_stream_name.LogStreamName",
log_events: "capo_cloudwatch_logs.types.input_log_events.InputLogEvents",
*,
config_overrides: Optional[CloudWatchLogsClientConfig] = None,
sequence_token: Optional[
"capo_cloudwatch_logs.types.sequence_token.SequenceToken"
] = None,
entity: Optional["capo_cloudwatch_logs.types.entity.Entity"] = None,
) -> "capo_cloudwatch_logs.types.put_log_events_response.PutLogEventsResponse":
"""<p>Uploads a batch of log events to the specified log stream.</p> <important> <p>The sequence token is now ignored in <code>PutLogEvents</code> actions. <code>PutLogEvents</code> actions are always accepted and never return <code>InvalidSequenceTokenException</code> or <code>DataAlreadyAcceptedException</code> even if the sequence token is not valid. You can use parallel <code>PutLogEvents</code> actions on the same log stream. </p> </important> <p>The batch of events must satisfy the following constraints:</p> <ul> <li> <p>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.</p> </li> <li> <p>Events more than 2 hours in the future are rejected while processing remaining valid events.</p> </li> <li> <p>Events older than 14 days or preceding the log group's retention period are rejected while processing remaining valid events.</p> </li> <li> <p>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 <code>Jan 1, 1970 00:00:00 UTC</code>. (In Amazon Web Services Tools for PowerShell and the Amazon Web Services SDK for .NET, the timestamp is specified in .NET format: <code>yyyy-mm-ddThh:mm:ss</code>. For example, <code>2017-09-15T13:45:30</code>.) </p> </li> <li> <p> A batch of log events in a single request must be in a chronological order. Otherwise, the operation fails.</p> </li> <li> <p>Each log event can be no larger than 1 MB.</p> </li> <li> <p>The maximum number of log events in a batch is 10,000.</p> </li> <li> <p>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.</p> </li> </ul> <important> <p>The quota of five requests per second per log stream has been removed. Instead, <code>PutLogEvents</code> actions are throttled based on a per-second per-account quota. You can request an increase to the per-second throttling quota by using the Service Quotas service.</p> </important> <p>If a call to <code>PutLogEvents</code> returns "UnrecognizedClientException" the most likely cause is a non-valid Amazon Web Services access key ID or secret key. </p>
Args:
log_group_name: <p>The name of the log group.</p>
log_stream_name: <p>The name of the log stream.</p>
log_events: <p>The log events.</p>
sequence_token: <p>The sequence token obtained from the response of the previous <code>PutLogEvents</code> call.</p> <important> <p>The <code>sequenceToken</code> parameter is now ignored in <code>PutLogEvents</code> actions. <code>PutLogEvents</code> actions are now accepted and never return <code>InvalidSequenceTokenException</code> or <code>DataAlreadyAcceptedException</code> even if the sequence token is not valid.</p> </important>
entity: <p>The entity associated with the log events.</p>
Raises:
capo_cloudwatch_logs.errors.data_already_accepted_exception.DataAlreadyAcceptedException: <p>The event was already logged.</p> <important> <p> <code>PutLogEvents</code> actions are now always accepted and never return <code>DataAlreadyAcceptedException</code> regardless of whether a given batch of log events has already been accepted. </p> </important>
capo_cloudwatch_logs.errors.invalid_parameter_exception.InvalidParameterException: <p>A parameter is specified incorrectly.</p>
capo_cloudwatch_logs.errors.invalid_sequence_token_exception.InvalidSequenceTokenException: <p>The sequence token is not valid. You can get the correct sequence token in the <code>expectedSequenceToken</code> field in the <code>InvalidSequenceTokenException</code> message. </p> <important> <p> <code>PutLogEvents</code> actions are now always accepted and never return <code>InvalidSequenceTokenException</code> regardless of receiving an invalid sequence token. </p> </important>
capo_cloudwatch_logs.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource does not exist.</p>
capo_cloudwatch_logs.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service cannot complete the request.</p>
capo_cloudwatch_logs.errors.unrecognized_client_exception.UnrecognizedClientException: <p>The most likely cause is an Amazon Web Services access key ID or secret key that's not valid.</p>
capo_cloudwatch_logs.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_cloudwatch_logs.types.put_log_events_request.PutLogEventsRequest]",
) -> OperationResponse[
"capo_cloudwatch_logs.types.put_log_events_response.PutLogEventsResponse"
]:
import capo_cloudwatch_logs._operations.logs_20140328.put_log_events
output, http_response = (
capo_cloudwatch_logs._operations.logs_20140328.put_log_events.put_log_events(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("PutLogEvents")
)
input_: capo_cloudwatch_logs.types.put_log_events_request.PutLogEventsRequest = {
"log_group_name": log_group_name,
"log_stream_name": log_stream_name,
"log_events": log_events,
}
if sequence_token is not None:
input_["sequence_token"] = sequence_token
if entity is not None:
input_["entity"] = entity
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|