Updated on 2024-04-12 GMT+08:00

Creating a Log Transfer Task (New Version)

Function

This API is used to transfer logs to OBS.

URI

POST /v2/{project_id}/transfers

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain a project ID, see Obtaining the Account Tenant ID, Log Group ID, and Log Stream ID.

Default: None

Minimum: 32

Maximum: 32

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token obtained from IAM.

Default: None

Minimum: 1000

Maximum: 2000

Content-Type

Yes

String

Set this parameter to application/json;charset=UTF-8.

Default: None

Minimum: 30

Maximum: 30

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

log_group_id

Yes

String

Log group ID.

Minimum: 36

Maximum: 36

log_streams

Yes

Array of log_streams objects

Log stream list.

Array Length: 1 - 1000

log_transfer_info

Yes

log_transfer_info object

Log transfer information.

Table 4 log_streams

Parameter

Mandatory

Type

Description

log_stream_id

Yes

String

Log stream ID.

Minimum: 36

Maximum: 36

log_stream_name

No

String

Log stream name.

Table 5 log_transfer_info

Parameter

Mandatory

Type

Description

log_transfer_type

Yes

String

Log transfer type. You can transfer logs to OBS.

log_transfer_mode

Yes

String

Log transfer mode. cycle indicates periodic transfer.

Enumeration values:

  • cycle

log_storage_format

Yes

String

Log transfer format. The value can be RAW or JSON. RAW indicates the raw log format, and JSON indicates the JSON format. Both JSON and RAW are available for OBS transfer tasks.

Enumeration values:

  • JSON

  • RAW

log_transfer_status

Yes

String

Log transfer status. The value can be ENABLE, DISABLE, or EXCEPTION. ENABLE indicates that log transfer is enabled, DISABLE indicates that log transfer is disabled, and EXCEPTION indicates that log transfer is abnormal.

Enumeration values:

  • ENABLE

  • DISABLE

  • EXCEPTION

log_agency_transfer

No

log_agency_transfer object

Information about delegated log transfer. This parameter is required if you transfer logs for another account.

log_transfer_detail

Yes

TransferDetail object

Log transfer details.

Table 6 log_agency_transfer

Parameter

Mandatory

Type

Description

agency_domain_id

Yes

String

Delegator account ID.

Minimum: 1

Maximum: 128

agency_domain_name

Yes

String

Delegator account name.

Minimum: 1

Maximum: 128

agency_name

Yes

String

Name of the agency created by the delegator.

Minimum: 1

Maximum: 128

agency_project_id

Yes

String

Project ID of the delegator.

Minimum: 32

Maximum: 32

be_agency_domain_id

Yes

String

Account ID of the delegated party (ID of the account that created the log transfer task).

Minimum: 1

Maximum: 128

be_agency_project_id

Yes

String

Project ID of the delegated party (project ID of the account that created the log transfer task).

Minimum: 32

Maximum: 32

Table 7 TransferDetail

Parameter

Mandatory

Type

Description

obs_period

Yes

Integer

Length of the transfer interval for an OBS transfer task. This parameter is required when you create an OBS transfer task. The log transfer interval is specified by the combination of the values of obs_period and obs_period_unit, and must be set to one of the following: 2 min, 5 min, 30 min, 1 hour, 3 hours, 6 hours, and 12 hours.

Enumeration values:

  • 1

  • 2

  • 3

  • 5

  • 6

  • 12

  • 30

obs_period_unit

Yes

String

Unit of the transfer interval for an OBS transfer task. This parameter is required when you create an OBS transfer task. The log transfer interval is specified by the combination of the values of obs_period and obs_period_unit, and must be set to one of the following: 2 min, 5 min, 30 min, 1 hour, 3 hours, 6 hours, and 12 hours.

Enumeration values:

  • "min"

  • "hour"

obs_bucket_name

Yes

String

OBS log bucket name. This parameter is required when you create an OBS transfer task.

Minimum: 3

Maximum: 63

obs_encrypted_id

No

String

KMS key ID for an OBS transfer task. This parameter is required if encryption is enabled for the target OBS bucket.

Minimum: 36

Maximum: 36

obs_dir_pre_fix_name

No

String

Custom transfer path of an OBS transfer task. This parameter is optional. The value must match the regular expression: ^(/)?([a-zA-Z0-9.-]+)(/[a-zA-Z0-9.-]+)*(/)?$

Minimum: 1

Maximum: 64

obs_prefix_name

No

String

Transfer file prefix of an OBS transfer task. This parameter is optional. The value must match the regular expression: ^[a-zA-Z0-9._-]*$

Minimum: 1

Maximum: 64

obs_time_zone

No

String

Time zone for an OBS transfer task. If this parameter is specified, obs_time_zone_id must also be specified.

obs_time_zone_id

No

String

ID of the time zone for an OBS transfer task. For details, see Time Zone List for OBS Transfer. If this parameter is specified, obs_time_zone must also be specified.

obs_transfer_path

No

String

OBS bucket path, which is the log transfer destination.

Minimum: 0

Maximum: 256

obs_encrypted_enable

No

Boolean

Whether OBS bucket encryption is enabled.

Enumeration values:

  • true

  • false

tags

No

Array of strings

If tag delivery is enabled, this field must contain the following host information: hostIP, hostId, hostName, pathFile, and collectTime.

The common fields include logStreamName, regionName, logGroupName and projectId, which are optional.

The transfer tag streamTag is optional.

Response Parameters

Status code: 200

Table 8 Response body parameters

Parameter

Type

Description

log_group_id

String

Log group ID.

Minimum: 36

Maximum: 36

log_group_name

String

Log group name.

Minimum: 1

Maximum: 64

log_streams

Array of log_streams objects

Log stream list.

Array Length: 1 - 1000

log_transfer_id

String

Log transfer task ID.

Minimum: 36

Maximum: 36

log_transfer_info

log_transfer_info object

Log transfer information.

Table 9 log_streams

Parameter

Type

Description

log_stream_id

String

Log stream ID.

Minimum: 36

Maximum: 36

log_stream_name

String

Log stream name.

Minimum: 1

Maximum: 64

Table 10 log_transfer_info

Parameter

Type

Description

log_agency_transfer

log_agency_transfer object

Information about delegated log transfer. This parameter is returned for a delegated log transfer task.

log_create_time

Long

Time when the log transfer task was created.

Minimum: 0

Maximum: 9999999999999

log_storage_format

String

Log transfer format. The value can be RAW or JSON. RAW indicates the raw log format, and JSON indicates the JSON format. Both JSON and RAW are available for OBS transfer tasks.

Enumeration values:

  • JSON

  • RAW

log_transfer_detail

TransferDetail object

Log transfer details.

log_transfer_mode

String

Log transfer mode. cycle indicates periodic transfer. Only cycle is available for OBS transfer tasks.

Enumeration values:

  • cycle

log_transfer_status

String

Log transfer status. ENABLE indicates that log transfer is enabled, DISABLE indicates that log transfer is disabled, and EXCEPTION indicates that log transfer is abnormal.

Enumeration values:

  • ENABLE

  • DISABLE

  • EXCEPTION

log_transfer_type

String

Log transfer type. You can transfer logs to OBS.

Enumeration values:

  • OBS

Table 11 log_agency_transfer

Parameter

Type

Description

agency_domain_id

String

Delegator account ID.

Minimum: 1

Maximum: 128

agency_domain_name

String

Delegator account name.

Minimum: 1

Maximum: 128

agency_name

String

Name of the agency created by the delegator.

Minimum: 1

Maximum: 128

agency_project_id

String

Project ID of the delegator.

Minimum: 32

Maximum: 32

be_agency_domain_id

String

Account ID of the delegated party (ID of the account that created the log transfer task).

Minimum: 1

Maximum: 128

be_agency_project_id

String

Project ID of the delegated party (project ID of the account that created the log transfer task).

Minimum: 32

Maximum: 32

Table 12 TransferDetail

Parameter

Type

Description

obs_period

Integer

Length of the transfer interval for an OBS transfer task. This parameter is required when you create an OBS transfer task. The log transfer interval is specified by the combination of the values of obs_period and obs_period_unit, and must be set to one of the following: 2 min, 5 min, 30 min, 1 hour, 3 hours, 6 hours, and 12 hours.

Enumeration values:

  • 1

  • 2

  • 3

  • 5

  • 6

  • 12

  • 30

obs_period_unit

String

Unit of the transfer interval for an OBS transfer task. This parameter is required when you create an OBS transfer task. The log transfer interval is specified by the combination of the values of obs_period and obs_period_unit, and must be set to one of the following: 2 min, 5 min, 30 min, 1 hour, 3 hours, 6 hours, and 12 hours.

Enumeration values:

  • "min"

  • "hour"

obs_bucket_name

String

OBS log bucket name. This parameter is required when you create an OBS transfer task.

Minimum: 3

Maximum: 63

obs_encrypted_id

String

KMS key ID for an OBS transfer task. This parameter is required if encryption is enabled for the target OBS bucket.

Minimum: 36

Maximum: 36

obs_dir_pre_fix_name

String

Custom transfer path of an OBS transfer task. This parameter is optional. The value must match the regular expression: ^(/)?([a-zA-Z0-9.-]+)(/[a-zA-Z0-9.-]+)*(/)?$

Minimum: 1

Maximum: 64

obs_prefix_name

String

Transfer file prefix of an OBS transfer task. This parameter is optional. The value must match the regular expression: ^[a-zA-Z0-9._-]*$

Minimum: 1

Maximum: 64

obs_time_zone

String

Time zone for an OBS transfer task. If this parameter is specified, obs_time_zone_id must also be specified.

obs_time_zone_id

String

ID of the time zone for an OBS transfer task. For details, see Time Zone List for OBS Transfer. If this parameter is specified, obs_time_zone must also be specified.

obs_transfer_path

String

OBS bucket path, which is the log transfer destination.

Minimum: 0

Maximum: 256

obs_encrypted_enable

Boolean

Whether OBS bucket encryption is enabled.

Enumeration values:

  • true

  • false

tags

Array of strings

If tag delivery is enabled, this field must contain the following host information: hostIP, hostId, hostName, pathFile, and collectTime.

The common fields include logStreamName, regionName, logGroupName and projectId, which are optional.

The transfer tag streamTag is optional.

Status code: 400

Table 13 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 500

Table 14 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

Minimum: 8

Maximum: 8

error_msg

String

Error message.

Minimum: 1

Maximum: 1000

Example Requests

The OBS transfer task has been created.

POST https://{endpoint}/v2/{project_id}/transfers

/v2/{project_id}/transfers 
{
    "log_group_id" : "8ba9e43f-be60-4d8c-9015-xxxxxxxxxxxx",
    "log_streams" : [{
            "log_stream_id" : "c776e1a7-8548-430a-afe5-xxxxxxxxxxxx"
        }
    ],
    "log_transfer_info" : {
        "log_transfer_type" : "OBS",
        "log_transfer_mode" : "xxxxx",
        "log_storage_format" : "XXX",
        "log_transfer_status" : "XXXXX",
        "log_agency_transfer" : {
            "agency_domain_id" : "1d26cc8c86a840e28a4f8d0d078xxxxx",
            "agency_domain_name" : "paas_apm_z004xxxxx_xx",
            "agency_name" : "test20210325",
            "agency_project_id" : "2a473356cca5487f8373be891bfxxxxx",
            "be_agency_domain_id" : "1d26cc8c86a840e28a4f8d0d078xxxxx",
            "be_agency_project_id" : "2a473356cca5487f8373be891bfxxxxx"
        },
        "log_transfer_detail" : {
            "obs_period" : 2,
            "obs_period_unit" : "min",
            "obs_bucket_name" : "xxxxx",
            "obs_encrypted_id" : "1bd90032-1424-481f-8558-ba49854xxxxx",
            "obs_dir_pre_fix_name" : "xx",
            "obs_prefix_name" : "xxxxx",
            "obs_time_zone": "UTC+01:00",
            "obs_time_zone_id": "Africa/Lagos"
        }
    }
}

Example Responses

Status code: 200

The log transfer task is created.

The following parameters are returned for an OBS transfer task:
{
    "log_group_id" : "9a7e2183-2d6d-4732-9a9b-e897fd4e49e0",
    "log_group_name" : "lts-group-kafka",
    "log_streams" : [{
            "log_stream_id" : "839dac89-35af-4db2-ab4a-a7dda0d0d3f8",
            "log_stream_name" : "lts-topic-kafka"
        }
    ],
    "log_transfer_id" : "ddced522-233a-4181-a5fc-7b458c819afc",
    "log_transfer_info" : {
        "log_create_time" : 1634802241847,
        "log_storage_format" : "JSON",
        "log_agency_transfer" : {
            "agency_domain_id" : "1d26cc8c86a840e28a4f8d0d078xxxxx",
            "agency_domain_name" : "paas_apm_z004xxxxx_xx",
            "agency_name" : "test20210325",
            "agency_project_id" : "2a473356cca5487f8373be891bfxxxxx",
            "be_agency_domain_id" : "1d26cc8c86a840e28a4f8d0d078xxxxx",
            "be_agency_project_id" : "2a473356cca5487f8373be891bfxxxxx"
        },
        "log_transfer_detail" : { 
            "obs_period":2,
            "obs_prefix_name":"",
            "obs_period_unit":"min",
            "obs_transfer_path":"/0002/LogTanks/XX/",
            "obs_bucket_name":"0002",
            "obs_encrypted_enable":false,
            "obs_dir_pre_fix_name":"",
            "obs_time_zone": "UTC+01:00",
            "obs_time_zone_id": "Africa/Lagos",
            "tags": []
        },
        "log_transfer_mode":"cycle",
        "log_transfer_status":"ENABLE",
        "log_transfer_type":"OBS"
    }
}

Status code: 400

Invalid request. Modify the request based on the description in error_msg before a retry.

{
  "error_code" : "LTS.0207",
  "error_msg" : "The log stream is associated by transfer"
}

Status code: 500

InternalServerError. The server has received the request but encountered an internal error.

{{    
  "error_code": "LTS.0010",    
  "error_msg": "Internal Server Error"
}

Status Codes

Status Code

Description

200

The log transfer task is created.

400

Invalid request. Modify the request based on the description in error_msg before a retry.

500

InternalServerError. The server has received the request but encountered an internal error.

Error Codes

See Error Codes.