Amazon CloudWatch Logs

2015/09/17 - Amazon CloudWatch Logs - 3 new api methods

CreateExportTask (new) Link ¶

Creates an ExportTask which allows you to efficiently export data from a Log Group to your Amazon S3 bucket.

This is an asynchronous call. If all the required information is provided, this API will initiate an export task and respond with the task Id. Once started, DescribeExportTasks can be used to get the status of an export task.

Request Syntax

client.create_export_task(
    taskName='string',
    logGroupName='string',
    logStreamNamePrefix='string',
    from=123,
    to=123,
    destination='string',
    destinationPrefix='string'
)
type taskName

string

param taskName

The name of the export task.

type logGroupName

string

param logGroupName

[REQUIRED]

The name of the log group to export.

type logStreamNamePrefix

string

param logStreamNamePrefix

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

type from

integer

param from

[REQUIRED]

A unix timestamp indicating the start time of the range for the request. Events with a timestamp prior to this time will not be exported.

type to

integer

param to

[REQUIRED]

A unix timestamp indicating the end time of the range for the request. Events with a timestamp later than this time will not be exported.

type destination

string

param destination

[REQUIRED]

Name of Amazon S3 bucket to which the log data will be exported. NOTE: Only buckets in the same AWS region are supported

type destinationPrefix

string

param destinationPrefix

Prefix that will be used as the start of Amazon S3 key for every object exported. If not specified, this defaults to 'exportedlogs'.

rtype

dict

returns

Response Syntax

{
    'taskId': 'string'
}

Response Structure

  • (dict) --

    • taskId (string) --

      Id of the export task that got created.

CancelExportTask (new) Link ¶

Cancels an export task if it is in PENDING or RUNNING state.

Request Syntax

client.cancel_export_task(
    taskId='string'
)
type taskId

string

param taskId

[REQUIRED]

Id of the export task to cancel.

returns

None

DescribeExportTasks (new) Link ¶

Returns all the export tasks that are associated with the AWS account making the request. The export tasks can be filtered based on TaskId or TaskStatus .

By default, this operation returns up to 50 export tasks that satisfy the specified filters. If there are more export tasks to list, the response would contain a nextToken value in the response body. You can also limit the number of export tasks returned in the response by specifying the limit parameter in the request.

Request Syntax

client.describe_export_tasks(
    taskId='string',
    statusCode='CANCELLED'|'COMPLETED'|'FAILED'|'PENDING'|'PENDING_CANCEL'|'RUNNING',
    nextToken='string',
    limit=123
)
type taskId

string

param taskId

Export task that matches the specified task Id will be returned. This can result in zero or one export task.

type statusCode

string

param statusCode

All export tasks that matches the specified status code will be returned. This can return zero or more export tasks.

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 DescribeExportTasks 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

{
    'exportTasks': [
        {
            'taskId': 'string',
            'taskName': 'string',
            'logGroupName': 'string',
            'from': 123,
            'to': 123,
            'destination': 'string',
            'destinationPrefix': 'string',
            'status': {
                'code': 'CANCELLED'|'COMPLETED'|'FAILED'|'PENDING'|'PENDING_CANCEL'|'RUNNING',
                'message': 'string'
            },
            'executionInfo': {
                'creationTime': 123,
                'completionTime': 123
            }
        },
    ],
    'nextToken': 'string'
}

Response Structure

  • (dict) --

    • exportTasks (list) --

      A list of export tasks.

      • (dict) --

        Represents an export task.

        • taskId (string) --

          Id of the export task.

        • taskName (string) --

          The name of the export task.

        • logGroupName (string) --

          The name of the log group from which logs data was exported.

        • from (integer) --

          A unix timestamp indicating the start time of the range for the request. Events with a timestamp prior to this time were not exported.

        • to (integer) --

          A unix timestamp indicating the end time of the range for the request. Events with a timestamp later than this time were not exported.

        • destination (string) --

          Name of Amazon S3 bucket to which the log data was exported.

        • destinationPrefix (string) --

          Prefix that was used as the start of Amazon S3 key for every object exported.

        • status (dict) --

          Status of the export task.

          • code (string) --

            Status code of the export task.

          • message (string) --

            Status message related to the code .

        • executionInfo (dict) --

          Execution info about the export task.

          • creationTime (integer) --

            A point in time when the export task got created.

          • completionTime (integer) --

            A point in time when the export task got completed.

    • 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.