Querying a Trace List

Function

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

URI

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

For details about the parameters, see Table 1.
Table 1 Parameters in the URI

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID.

tracker_name

Yes

String

Currently, only tracker "system" is available.

Request

  • Parameters
    Table 2 Parameters in the request

    Parameter

    Mandatory

    Type

    Description

    service_type

    No

    String

    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

    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

    ID of a resource whose traces are to be queried.

    resource_name

    No

    String

    Name of a resource whose traces are to be queried.

    NOTE:

    The value may contain uppercase letters.

    trace_name

    No

    String

    Operation recorded by this trace.

    NOTE:

    The value may contain uppercase letters.

    limit

    No

    String

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

    next

    No

    String

    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

    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

    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

    ID of a trace.

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

    trace_status

    No

    String

    Status of a trace. The value can be normal, warning, or incident.

    user

    No

    String

    Specified username whose traces are to be queried.

    NOTE:

    The value may contain uppercase letters.

  • Example request
    GET 
    /v2.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

    Trace array in the trace list.

    meta_data

    Structure

    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

    ID of a resource on which operations are performed.

    trace_name

    String

    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_status

    String

    Status of a trace. The value can be normal, warning, or incident.

    trace_type

    String

    Resource of a trace. The value can be ApiCall, ConsoleAction, or SystemAction.

    request

    Structure

    Request of an operation on resources.

    response

    Structure

    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

    Version of the API.

    message

    String

    Remarks added by other cloud services to a trace.

    record_time

    Long

    Timestamp when a trace is recorded by CTS.

    trace_id

    String

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

    time

    Long

    Time when a trace occurs.

    user

    Structure

    User information for which a trace is triggered.

    service_type

    String

    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

    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

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

    resource_name

    String

    Name of a resource whose traces are to be queried.

    request_id

    String

    Record the ID of the request.

    location_info

    String

    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 description of the meta_data field

    Parameter

    Type

    Description

    count

    Integer

    Number of traces returned in the trace list.

    marker

    String

    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","id":"a2e899190fcd444084a68fc0ac2sc1e9","domain":{"name":"xxx","id":"05b2598d69bc4a209f9ac5eeeb1f91ad"}}, 
        "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_status " : "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","id":"a2e899190fcd444084a68fc0ac2sc1e9","domain":{"name":"xxx","id":"05b2598d69bc4a209f9ac5eeeb1f91ad"}}, 
    "request": {"servers":[{"id":"3045f042-9a7c-436d-a944-ff76ceb7b477"}],"delete_volume":false,"delete_publicip":false},
        "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_status" : "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.