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

Querying Log Streams

Function

This API is used to query log streams.

Calling Method

For details, see Calling APIs.

URI

GET /v2/{project_id}/log-streams

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 Project ID, Account ID, Log Group ID, and Log Stream ID.

Minimum: 32

Maximum: 32

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

log_group_name

No

String

Log group name.

Minimum: 1

Maximum: 64

log_stream_name

No

String

Log stream name.

Minimum: 1

Maximum: 64

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token obtained from IAM. For details about how to obtain a user token, see Obtaining a User Token.

Minimum: 1000

Maximum: 2000

Content-Type

Yes

String

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

Minimum: 30

Maximum: 30

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

log_streams

Array of LogStreamNoIsFavorite objects

List of log groups.

Table 5 LogStreamNoIsFavorite

Parameter

Type

Description

creation_time

Long

Time when a log stream is created.

Minimum: 1577808000000

Maximum: 4102416000000

log_stream_id

String

Log stream ID.

Minimum: 36

Maximum: 36

log_stream_name

String

Log stream name.

Minimum: 1

Maximum: 64

log_stream_name_alias

String

Log stream alias.

tag

Map<String,String>

Log stream tag.

filter_count

Integer

Number of filters.

Minimum: 0

Maximum: 5

hot_cold_separation

String

Hot and cold storage switch.

whether_log_storage

String

Whether to enable log storage.

auth_web_tracking

String

Anonymous write switch.

ttl_in_days

String

Log storage duration (days).

hot_storage_days

String

Standard storage duration (days).

Status code: 400

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

Minimum: 8

Maximum: 8

error_msg

String

Error message.

Status code: 500

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

Minimum: 8

Maximum: 8

error_msg

String

Error message.

Example Requests

If you leave the request body empty, all log streams are queried. If log_group_name and log_stream_name are specified, the corresponding log stream is queried.

GET https://{endpoint}/v2/{project_id}/log-streams

/v2/{project_id}/log-streams /v2/{project_id}/log-streams?log_group_name=lts-group-txxxx
/v2/{project_id}/log-streams?log_stream_name=lts-xunjian-topic-xxxx 
/v2/{project_id}/log-streams?log_stream_name=lts-xunjian-topic-xxxx&log_group_name=lts-group-xxx

Example Responses

Status code: 200

Log stream information is returned.

{
  "log_streams" : [ {
    "log_stream_name_alias" : "lts-topic-xxxx",
    "creation_time" : 1698915657847,
    "auth_web_tracking" : false,
    "log_stream_name" : "lts-topic-xxxx",
    "is_favorite" : false,
    "hot_storage_days" : -1,
    "tag" : {
      "_sys_enterprise_project_id" : "xxxxxx"
    },
    "hot_cold_separation" : false,
    "filter_count" : 0,
    "log_stream_id" : "xxxxxxx",
    "ttl_in_days" : 7,
    "whether_log_storage" : true
  }, {
    "log_stream_name_alias" : "lts-topic-xxxx",
    "creation_time" : 1698915650021,
    "auth_web_tracking" : false,
    "log_stream_name" : "lts-topic-xxxx",
    "is_favorite" : false,
    "hot_storage_days" : -1,
    "tag" : {
      "_sys_enterprise_project_id" : "xxxxxxx"
    },
    "hot_cold_separation" : false,
    "filter_count" : 0,
    "log_stream_id" : "xxxxxxxxxxxxxxxxxxx",
    "ttl_in_days" : 7,
    "whether_log_storage" : true
  } ]
}

Status code: 400

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

{
  "error_code" : "LTS.0205",
  "error_msg" : "The log stream name has been existed"
}

Status code: 500

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

{
  "error_code" : "LTS.0010",
  "error_msg" : "The system encountered an internal error"
}

Status Codes

Status Code

Description

200

Log stream information is returned.

400

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

500

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

Error Codes

See Error Codes.