• Cloud Trace Service

cts
  1. Help Center
  2. Cloud Trace Service
  3. API Reference
  4. API Description
  5. Trace Management
  6. Querying a Trace (v1.0)

Querying a Trace (v1.0)

Function

This API is used to query records of operations performed on resources in the last seven days.

URI

GET /v1.0/{project_id}/{tracker_name}/trace{?trace_id,service_type,resource_type,resource_id,resource_name,trace_name,trace_rating,user,limit,from,to,next}

For details about the parameters, see Querying a Trace (v1.0).
Table 1 Parameters in the URI

Parameter

Mandatory

Type

Description

project_id

Yes

String

Specifies the project ID.

tracker_name

Yes

String

Specifies the tracker name. Currently, only tracker "system" is available.

Request

  • Parameters
    Table 2 Parameters in the request

    Parameter

    Mandatory

    Type

    Description

    service_type

    No

    String

    Specifies the type of a service whose traces are to be queried. The value must be the abbreviation of a cloud service that has been interconnected with CTS. It is a word composed of uppercase letters. For the interconnected cloud services, see section "Supported Services" in the Cloud Trace Service User Guide.

    resource_type

    No

    String

    Specifies the type of a resource whose traces are to be queried. The value is a string of 1 to 64 characters and can contain uppercase and lowercase letters (a to z and A to Z), digits (0 to 9), hyphens (-), underscores (_), and periods (.). In addition, it must start with a letter. For the interconnected cloud services, see section "Supported Services" in the Cloud Trace Service User Guide.

    resource_id

    No

    String

    Specifies the ID of a resource whose traces are to be queried.

    resource_name

    No

    String

    Specifies the name of a resource whose traces are to be queried.

    trace_name

    No

    String

    Specifies the operation recorded by this trace. The value is a string of 1 to 64 characters and can contain uppercase and lowercase letters (a to z and A to Z), digits (0 to 9), hyphens (-), underscores (_), and periods (.). In addition, it must start with a letter.

    limit

    No

    String

    Specifies the number of traces returned in the trace list. The default value is 50 and the maximum value is 200.

    next

    No

    String

    Specifies the time of a queried trace (you can query traces earlier than the time). The value can be the parameter marker value in Table 5.

    The time condition next can be used with another time condition from and to.

    The final query condition is the intersection of the preceding two conditions.

    from

    No

    String

    Specifies the starting timestamp of the queried trace. The value is in UTC format, accurate to ms, and contains 13 digits. The time spent in selecting this filter is excluded. from and to are both used.

    to

    No

    String

    Specifies the ending timestamp of the queried trace. The value is in UTC format, accurate to ms, and contains 13 digits. The time spent in selecting this filter is excluded. The query criteria to and from are both used.

    trace_id

    No

    String

    Specifies the ID of a trace.

    If this parameter is used as a filter, other filters cannot be selected.

    trace_rating

    No

    String

    Specifies the status of a trace. The value can be normal, warning, or incident.

    user

    No

    String

    Specifies a username whose traces are to be queried.

    NOTE:

    The value may contain uppercase letters.

  • Example request
    GET /v1.0/{project_id}/{tracker_name}/trace?limit=11&to=1479095278000&from=1478490478000&trace_name=createTracker&resource_type=tracker&service_type=CTS

Response

  • Parameters
    Table 3 Parameters in the response

    Parameter

    Type

    Description

    traces

    array

    Specifies the trace array in the trace list.

    meta_data

    Structure

    Specifies the extended field. The value can be count (number of traces in the response) or marker (ID of the last trace in the trace list).

    Table 4 Data structure description of the traces field

    Parameter

    Type

    Description

    resource_id

    String

    Specifies the ID of a resource on which operations are performed.

    trace_name

    String

    Specifies the name of a trace. The value is a string of 1 to 64 characters and can contain uppercase and lowercase letters (a to z and A to Z), digits (0 to 9), hyphens (-), underscores (_), and periods (.). In addition, it must start with a letter.

    trace_rating

    String

    Specifies the status of a trace. The value can be normal, warning, or incident.

    trace_type

    String

    Specifies the resource of a trace. The value can be ApiCall, ConsoleAction, or SystemAction.

    request

    String

    Specifies the request of an operation on resources.

    response

    String

    Specifies the response to a user request, that is, the returned information for an operation on resources.

    code

    String

    Records the response to a user request and specifies the HTTP status code returned by the API recorded in the trace.

    api_version

    String

    Specifies the version of the API.

    message

    String

    Specifies the remarks added by other cloud services to a trace.

    record_time

    Long

    Specifies the timestamp when a trace is recorded by CTS.

    trace_id

    String

    Specifies the ID of a trace. The value is the UUID generated by the system.

    time

    Long

    Specifies the time when a trace occurs.

    user

    String

    Specifies the user information for which a trace is triggered.

    service_type

    String

    Specifies the type of a service whose traces are to be queried. The value must be the abbreviation of a cloud service that has been interconnected with CTS. It is a word composed of uppercase letters.

    resource_type

    String

    Specifies the type of a resource whose traces are to be queried. The value is a string of 1 to 64 characters and can contain uppercase and lowercase letters (a to z and A to Z), digits (0 to 9), hyphens (-), underscores (_), and periods (.). In addition, it must start with a letter.

    source_ip

    String

    Specifies the IP address of a user for whom a trace is triggered.

    resource_name

    String

    Specifies the name of a resource whose traces are to be queried.

    request_id

    String

    Specifies the ID of a request.

    location_info

    String

    Specifies the additional information required for fault locating after a request recording error occurs.

    endpoint

    String

    This operation involves the endpoint of the page that displays cloud resource details.

    resource_url

    String

    This operation involves the access link (excluding the endpoint) of the page that displays cloud resource details.

    Table 5 Data structure of the meta_data field

    Parameter

    Type

    Description

    count

    Integer

    Specifies the trace array in the trace list.

    marker

    String

    Specifies the ID of the last trace in the trace list. The value of this parameter can be used as the next value. If the value of marker is null, all traces have been returned.

  • Example response
    {
      "traces" : [ {
        "time" : 1472148708232,
        "user" : "{\"name\":\"xxx\",\"domain\":{\"name\":\"xxx\",\"id\":\"ded649d814464428ba89d04d7955c93e\"},\"assumedBy\":{\"user\":{\"name\":\"bss_bm_admin\",\"id\":\"c5140af45b5d4b399dea8f900f1dcf1b\",\"domain\":{\"name\":\"op_service\",\"id\":\"71ce673175024d0495664e525e52bac0\"}}}}",
        "response" : "{\"code\":\"VPC.0514\",\"message\":\"Update port fail.\"}",
        "code" : 200,
        "service_type" : "VPC",
        "resource_type" : "eip",
        "resource_name" : "192.144.163.1",
        "resource_id" : "d502809d-0d1d-41ce-9690-784282142ccc",
        "trace_name" : "deleteEip",
        "trace_rating" : "warning",
        "trace_type" : "ConsoleAction",
        "api_version" : "2.0",
        "record_time" : 1481066128032,
        "trace_id" : "e001ccb9-bc09-11e6-b00b-4b2a61338db6"
        "request_id" : "a0001c1b9-bctt-2136-c12b-4b2a611116"
        "location_info" : "resource has been deleted"
        "endpoint" : "https://*****/vpc?agencyId=***&region=***&locale=zh-cn#"
        "resource_url" : "/vpc/vpcmanager/vpcs?vpcid=*****"
      }, {
        "time" : 1472148708232,
        "user" : "{\"name\":\"xxx\",\"domain\":{\"name\":\"xxx\",\"id\":\"ded649d814464428ba89d04d7955c93e\"},\"assumedBy\":{\"user\":{\"name\":\"bss_bm_admin\",\"id\":\"c5140af45b5d4b399dea8f900f1dcf1b\",\"domain\":{\"name\":\"op_service\",\"id\":\"71ce673175024d0495664e525e52bac0\"}}}}",
        "response" : "{\"code\":\"VPC.0514\",\"message\":\"Update port fail.\"}",
        "code" : 200,
        "service_type" : "VPC",
        "resource_type" : "eip",
        "resource_name" : "192.144.163.1",
        "resource_id" : "d502809d-0d1d-41ce-9690-784282142ccc",
        "trace_name" : "deleteEip",
        "trace_rating" : "warning",
        "trace_type" : "ConsoleAction",
        "api_version" : "2.0",
        "record_time" : 1481066128032,
        "trace_id" : "e001ccb8-bc09-11e6-b2cc-2640a43cc6e8"
        "request_id" : "a0001c1b9-bctt-2136-c12b-4b2a611116"
        "location_info" : "resource has been deleted"
        "endpoint" : "https://*****/vpc?agencyId=***&region=***&locale=zh-cn#"
        "resource_url" : "/vpc/vpcmanager/vpcs?vpcid=*****"
      } ],
      "meta_data" : {
        "count" : 2,
        "marker" : "e001ccb8-bc09-11e6-b2cc-2640a43cc6e8"
      }
    }

Returned Value

  • Normal
    Table 6 Return code for successful requests

    Returned Value

    Description

    200

    The request is successful and the query result is returned.

  • Abnormal
    Table 7 Return code for failed requests

    Returned Value

    Description

    400

    The query parameters are abnormal.

    500

    Failed to complete the request because of an internal service error.

    401

    Your access request is rejected.

    403

    You are forbidden to access the requested page.

    404

    The requested trace does not exist.