• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. API Reference
  4. Metrics and Logs (Proprietary APIs)
  5. Application Logs

Application Logs

Function

This API is used to export the logs generated by containerized applications in a specified time period.

URI

GET /api/v1/container/clusters/{clusteruuid}/pods/{poduuid}/logsfile

Table 1 describes the parameters of this API.
Table 1 Parameter description

Parameter

Mandatory

Description

clusteruuid

Yes

UUID of the container cluster.

poduuid

Yes

Pod UUID.

To obtain the Pod UUID, perform the following steps:

  1. Call API GET /api/v1/namespaces to obtain the namespace where the containerized application resides. For reference, see Listing or Watching Objects of Kind Namespace.
NOTE:

If the containerized application is created using the CCE console, the namespace name is default. If the containerized application is created by calling the API, the namespace name is user-defined.

  1. Call API GET /api/v1/namespaces/${namespace} /pods/ to obtain the Pod UUID in the namespace. For reference, see Listing or Watching Objects of Kind Pod in a Specified Namespace.

stream

Yes

Log source.

Options:

  • stdout: standard output logs.
  • stderr: standard error logs.
  • *: standard output logs and standard error logs.

keyword

No

Keyword used to search for matching logs.

* indicates that no keyword is defined.

log_time

Yes

Time period over which logs are queried.

log_time in the format of {"start_time":"*","end_time":"*"}.

log_lines

Yes

Number of returned log lines.

log_lines in the format of {"from":"*","to":"*"}.

Request

Request parameters:

N/A

Example request:

curl "http://{cce-domain-name}/api/v1/container/clusters/{clusteruuid}/pods/{poduuid}/logsfile" -X GET -d '{"stream":"*","keyword":"*","log_time":{"start_time":"*","end_time":"*"},"log_lines":{"from":"0","to":"100"}}' -i -H "Content-Type: application/json"

Response

Response parameter:

Table 2 describes the response parameters.

Table 2 Response parameters

Parameter

Type

Description

@timestamp

String

Time at which the log is saved.

log

String

Log content.

stream

String

Log source.

Options:

  • stdout: standard output logs.
  • stderr: standard error logs.
  • *: standard output logs and standard error logs.

time

String

Time (unit: µs) at which the log is generated.

Example response:

{
    "@timestamp": "2017-05-11T06:29:58.107Z",
    "log": "2017-05-11 06:29:18 62 [Note] Shutting down plugin 'INNODB_CMP_RESET'\n",
    "stream": "stderr",
    "time": "1509068308213568974"
}

Status Code

Table 3 describes the status code of this API.

Table 3 Status code

Status Code

Description

200

Application logs are exported successfully.

For the description about status codes, see section Status Codes.