Querying Traces (v2.0)¶
Function¶
This API is used to query records of operations on resources in the last seven days.
URI¶
GET /v2.0/{project_id}/{tracker_name}/trace
Parameter | Mandatory | Type | Description |
---|---|---|---|
project_id | Yes | String | Project ID. For details about how to obtain a project ID, see Obtaining a Project ID. |
tracker_name | Yes | String | Tracker name. Currently, only one tracker is allowed for each tenant. The tracker name is system. |
Parameter | Mandatory | Type | Description |
---|---|---|---|
service_type | No | String | Type of a cloud service whose traces are to be queried. The value must be the acronym of a cloud service that has been connected with CTS. It is a word composed of uppercase letters. For cloud services that can be connected with CTS, see section "Supported Services and Operations" in Cloud Trace Service User Guide. You can click the document link of each cloud service to view its name abbreviation. |
user | No | String | Name of the user whose traces are to be queried. |
from | No | Long | UTC millisecond timestamp of the query start time. The value contains 13 digits and the default value is the timestamp of the last hour. Traces generated after the specified timestamp will be queried. The parameters from and to should be used together. |
limit | No | Integer | Number of traces to query. The default value is 10 and the maximum value is 200. |
next | No | String | This parameter is used to query traces generated earlier than its specified value. The value can be that of marker in the response. next can be used with from and to. Traces generated in the overlap of the two time ranges specified respectively by next and by from and to will be returned. |
resource_id | No | String | ID of a cloud resource whose traces are to be queried. |
resource_name | No | String | Name of a resource whose traces are to be queried. The value can contain uppercase letters. |
resource_type | No | String | Type of a resource whose traces are to be queried. |
to | No | Long | UTC millisecond timestamp of the query end time. The value contains 13 digits and the default value is the timestamp of the current time. Traces generated before the specified timestamp will be queried. The parameters to and from should be used together. |
trace_id | No | String | Trace ID. If this parameter is specified, other query criteria will not take effect. |
trace_name | No | String | Trace name. The value can contain uppercase letters. |
trace_rating | No | String | Trace status. The value can be normal, warning, or incident. |
Request Parameters¶
None
Response Parameters¶
Status code: 200
Parameter | Type | Description |
---|---|---|
traces | Array of Traces objects | List of returned traces. |
meta_data | MetaData object | Number of returned traces and the marker. |
Parameter | Type | Description |
---|---|---|
resource_id | String | ID of a cloud resource on which the recorded operation was performed. |
trace_name | String | Trace name. The value can contain 1 to 64 characters, including letters, digits, hyphens (-), underscores (_), and periods (.). It must start with a letter. |
trace_rating | String | Trace status. The value can be normal, warning, or incident. Value:
|
trace_type | String | Trace source. The value can be ApiCall, ConsoleAction, or SystemAction. |
request | String | Request of an operation on resources. |
response | String | Response to a user request, that is, the returned information for an operation on resources. |
code | String | HTTP status code returned by the associated API. |
api_version | String | Version of the API called in a trace. |
message | String | Remarks added by other cloud services to a trace. |
record_time | Long | Timestamp when a trace was recorded by CTS. |
trace_id | String | Trace ID. The value is the UUID generated by the system. |
time | Long | Timestamp when a trace was generated. |
user | UserInfo object | Information of the user who performed the operation that triggered the trace. |
service_type | String | Type of a cloud service whose traces are to be queried. The value must be the acronym of a cloud service that has been connected with CTS. It is a word composed of uppercase letters. For cloud services that can be connected with CTS, see section "Supported Services and Operations" in Cloud Trace Service User Guide. You can click the document link of each cloud service to view its name abbreviation. |
resource_type | String | Type of the resource on which the operation was performed. |
source_ip | String | IP address of the tenant who performed the operation that triggered the trace. |
resource_name | String | Name of a resource on which the recorded operation was performed. |
request_id | String | Request ID. |
location_info | String | Additional information required for fault locating after a request error. |
endpoint | String | Endpoint in the details page URL of the cloud resource on which the recorded operation was performed. |
resource_url | String | Details page URL (excluding the endpoint) of the cloud resource on which the recorded operation was performed. |
Parameter | Type | Description |
---|---|---|
id | String | Account ID. For details about how to obtain an account ID, see Obtaining an Account ID. |
name | String | Account name. |
domain | BaseUser object | Domain information of the user who performed the operation generating the trace. |
Parameter | Type | Description |
---|---|---|
id | String | Account ID. For details about how to obtain an account ID, see Obtaining an Account ID. |
name | String | Account name. |
Parameter | Type | Description |
---|---|---|
count | Integer | Number of returned traces. |
marker | String | ID of the last trace in the returned trace list. The value of this parameter can be used as the value of next. If the value of marker is null, all traces have been returned under the specified query criteria. |
Example Request¶
GET https://{endpoint}/v2.0/{project_id}/{tracker_name}/trace?limit=11&to=1479095278000&from=1478490478000&trace_name=createTracker&resource_type=tracker&service_type=CTS
Example Response¶
Status code: 200
The request is successful.
{
"meta_data" : {
"count" : 2,
"marker" : "e001ccb8-bc09-11e6-b2cc-2640a43cc6e8"
},
"traces" : [ {
"time" : 1472148708232,
"user" : {
"name" : "xxx",
"domain" : {
"name" : "xxx",
"id" : "ded649d814464428ba89d04d7955c93e"
}
},
"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"
}, {
"time" : 1472148708232,
"user" : {
"name" : "xxx",
"domain" : {
"name" : "xxx",
"id" : "ded649d814464428ba89d04d7955c93e"
}
},
"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"
} ]
}
Status Codes¶
Status Code | Description |
---|---|
200 | The request is successful. |
400 | The request is not completed due to abnormal query parameters. |
401 | The request is rejected due to authentication failure. |
403 | The server understood the request but refused to authorize it. |
404 | The requested traces do not exist. |
500 | Failed to complete the request because of an internal service error. |
503 | The requested service is invalid. The client should not repeat the request without modifications. |
Error Codes¶
For details, see Error Codes.