Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com> Co-authored-by: Ying, Jiayu <jiayuying1@huawei.com> Co-committed-by: Ying, Jiayu <jiayuying1@huawei.com>
43 KiB
Querying Traces (v2.0)
Function
This API is used to query records of operations on resources in the last seven days. In v2.0, the request parameter trace_rating is changed to trace_status, and the type of response parameter user is changed to Structure.
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}
Request
- Parameter description
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 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 the Cloud Trace Service User Guide.
resource_type
No
String
Type of a resource whose traces are to be queried. The value can contain 1 to 64 characters, including letters, digits, hyphens (-), underscores (_), and periods (.). It must start with a letter. For cloud services that can be connected with CTS, see section "Supported Services and Operations" in the Cloud Trace Service User Guide.
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.
NOTE:The resource name is case sensitive.
trace_name
No
String
Trace name. It indicates the operation recorded by this trace.
NOTE:The trace name is case sensitive.
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
This parameter is used to query traces generated earlier than its specified value. The value can be that of marker in Table 5.
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.
from
No
String
UTC timestamp of the start time of the query time range. The value is in milliseconds and contains 13 digits. Traces generated on the specified timestamp are not returned. The parameters from and to should be used together.
to
No
String
UTC timestamp of the end time of the query time range. The value is in milliseconds and contains 13 digits. Traces generated on the specified timestamp are not returned. 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_status
No
String
Status of a trace. The value can be normal, warning, or incident.
user
No
String
Name of the user whose traces are to be queried.
NOTE:The username is case sensitive.
- 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
- Parameter description
Table 3 Parameters in the response Parameter
Type
Description
traces
array
List of returned traces.
meta_data
Structure
Extended parameter. 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 of the traces parameter Parameter
Type
Description
resource_id
String
ID of a cloud resource on which the recorded operation was performed.
trace_name
String
Name of a trace. The value can contain 1 to 64 characters, including letters, digits, hyphens (-), underscores (_), and periods (.). It must start with a letter.
trace_status
String
Trace status. The value can be normal, warning, or incident.
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.
message
String
Remarks added by other cloud services to a trace.
record_time
Long
Timestamp when an operation 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
Structure
Information of the user who performed the operation that triggered the trace.
service_type
String
Type of a 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.
resource_type
String
Type of a resource whose traces are to be queried. The value can contain 1 to 64 characters, including letters, digits, hyphens (-), underscores (_), and periods (.). It must start with a letter.
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.
Table 5 Data structure of the meta_data parameter 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 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=***®ion=***&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_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=***®ion=***&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
The request is rejected due to authentication failure.
403
The server understood the request but refused to authorize it.
404
The requested trace does not exist.