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 (v1.0)
Function
This API is used to query records of operations 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}
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 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 can contain 1 to 64 characters, including letters, numbers, hyphens (-), underscores (_), and periods (.). 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
trace_name
No
String
Trace name. It indicates the operation recorded by this trace. The value can contain 1 to 64 characters, including letters, numbers, hyphens (-), underscores (_), and periods (.). It must start with a letter.
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 the parameters 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 numbers. 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 numbers. Traces generated on the specified timestamp are not returned. The parameters to and from should be used together.
trace_id
No
String
ID of a trace.
If this parameter is specified, other query criteria will not take effect.
trace_rating
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 /v1.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 resource on which an operation was performed
trace_name
String
Name of a trace. The value will contain 1 to 64 characters, including letters, numbers, hyphens (-), underscores (_), and periods (.). It will also start with a letter.
trace_rating
String
Status of a trace. The value can be normal, warning, or incident.
trace_type
String
Type of a source trace. 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
ID of a trace. The value is the UUID generated by the system.
time
Long
Timestamp when an operation occurred
user
String
Information of the user who performed the operation that triggered the trace.
service_type
String
Type of a service whose traces were queried. The value is 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 were queried. The value will contain 1 to 64 characters, including letters, numbers, hyphens (-), underscores (_), and periods (.). It will also start with a letter.
source_ip
String
IP address of the user who performed the operation that triggered the trace.
resource_name
String
Name of a resource whose traces were queried
request_id
String
Request ID
location_info
String
Additional information required for fault locating after a request error
endpoint
String
Endpoint in the detail page URL of the cloud resource on which the recorded operation was performed
resource_url
String
Detail 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 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\",\"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=***®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_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=***®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
Your access request is rejected.
403
You are forbidden to access the requested page.
404
The requested trace does not exist.