Amazon CloudWatch Logs

2015/03/12 - Amazon CloudWatch Logs - 2 updated api methods

DescribeLogStreams (updated) Link ¶
Changes (request)
{'descending': 'boolean', 'orderBy': 'LogStreamName | LastEventTime'}

Returns all the log streams that are associated with the specified log group. The list returned in the response is ASCII-sorted by log stream name.

By default, this operation returns up to 50 log streams. If there are more log streams to list, the response would contain a nextToken value in the response body. You can also limit the number of log streams returned in the response by specifying the limit parameter in the request. This operation has a limit of five transactions per second, after which transactions are throttled.

Request Syntax

client.describe_log_streams(
    logGroupName='string',
    logStreamNamePrefix='string',
    orderBy='LogStreamName'|'LastEventTime',
    descending=True|False,
    nextToken='string',
    limit=123
)
type logGroupName

string

param logGroupName

[REQUIRED]

type logStreamNamePrefix

string

param logStreamNamePrefix

Will only return log streams that match the provided logStreamNamePrefix. If you don't specify a value, no prefix filter is applied.

type orderBy

string

param orderBy

Specifies what to order the returned log streams by. Valid arguments are 'LogStreamName' or 'LastEventTime'. If you don't specify a value, results are ordered by LogStreamName. If 'LastEventTime' is chosen, the request cannot also contain a logStreamNamePrefix.

type descending

boolean

param descending

If set to true, results are returned in descending order. If you don't specify a value or set it to false, results are returned in ascending order.

type nextToken

string

param nextToken

A string token used for pagination that points to the next page of results. It must be a value obtained from the response of the previous DescribeLogStreams request.

type limit

integer

param limit

The maximum number of items returned in the response. If you don't specify a value, the request would return up to 50 items.

rtype

dict

returns

Response Syntax

{
    'logStreams': [
        {
            'logStreamName': 'string',
            'creationTime': 123,
            'firstEventTimestamp': 123,
            'lastEventTimestamp': 123,
            'lastIngestionTime': 123,
            'uploadSequenceToken': 'string',
            'arn': 'string',
            'storedBytes': 123
        },
    ],
    'nextToken': 'string'
}

Response Structure

  • (dict) --

    • logStreams (list) -- A list of log streams.

      • (dict) -- A log stream is sequence of log events that share the same emitter.

        • logStreamName (string) --

        • creationTime (integer) -- A point in time expressed as the number milliseconds since Jan 1, 1970 00:00:00 UTC.

        • firstEventTimestamp (integer) -- A point in time expressed as the number milliseconds since Jan 1, 1970 00:00:00 UTC.

        • lastEventTimestamp (integer) -- A point in time expressed as the number milliseconds since Jan 1, 1970 00:00:00 UTC.

        • lastIngestionTime (integer) -- A point in time expressed as the number milliseconds since Jan 1, 1970 00:00:00 UTC.

        • uploadSequenceToken (string) -- A string token used for making PutLogEvents requests. A sequenceToken can only be used once, and PutLogEvents requests must include the sequenceToken obtained from the response of the previous request.

        • arn (string) --

        • storedBytes (integer) --

    • nextToken (string) -- A string token used for pagination that points to the next page of results. It must be a value obtained from the response of the previous request. The token expires after 24 hours.

PutLogEvents (updated) Link ¶
Changes (response)
{'rejectedLogEventsInfo': {'expiredLogEventEndIndex': 'integer',
                           'tooNewLogEventStartIndex': 'integer',
                           'tooOldLogEventEndIndex': 'integer'}}

Uploads a batch of log events to the specified log stream.

Every PutLogEvents request must include the sequenceToken obtained from the response of the previous request. An upload in a newly created log stream does not require a sequenceToken .

The batch of events must satisfy the following constraints:

  • The maximum batch size is 1,048,576 bytes, and this size is calculated as the sum of all event messages in UTF-8, plus 26 bytes for each log event.

  • None of the log events in the batch can be more than 2 hours in the future.

  • None of the log events in the batch can be older than 14 days or the retention period of the log group.

  • The log events in the batch must be in chronological ordered by their timestamp .

  • The maximum number of log events in a batch is 10,000.

Request Syntax

client.put_log_events(
    logGroupName='string',
    logStreamName='string',
    logEvents=[
        {
            'timestamp': 123,
            'message': 'string'
        },
    ],
    sequenceToken='string'
)
type logGroupName

string

param logGroupName

[REQUIRED]

type logStreamName

string

param logStreamName

[REQUIRED]

type logEvents

list

param logEvents

[REQUIRED] A list of events belonging to a log stream.

  • (dict) -- A log event is a record of some activity that was recorded by the application or resource being monitored. The log event record that Amazon CloudWatch Logs understands contains two properties: the timestamp of when the event occurred, and the raw event message.

    • timestamp (integer) -- [REQUIRED] A point in time expressed as the number milliseconds since Jan 1, 1970 00:00:00 UTC.

    • message (string) -- [REQUIRED]

type sequenceToken

string

param sequenceToken

A string token that must be obtained from the response of the previous PutLogEvents request.

rtype

dict

returns

Response Syntax

{
    'nextSequenceToken': 'string',
    'rejectedLogEventsInfo': {
        'tooNewLogEventStartIndex': 123,
        'tooOldLogEventEndIndex': 123,
        'expiredLogEventEndIndex': 123
    }
}

Response Structure

  • (dict) --

    • nextSequenceToken (string) -- A string token used for making PutLogEvents requests. A sequenceToken can only be used once, and PutLogEvents requests must include the sequenceToken obtained from the response of the previous request.

    • rejectedLogEventsInfo (dict) --

      • tooNewLogEventStartIndex (integer) --

      • tooOldLogEventEndIndex (integer) --

      • expiredLogEventEndIndex (integer) --