Domain name for API request: cfw.intl.tencentcloudapi.com.
This API is used to retrieve and analyze logs. Please note the following matters when using this API.
A maximum of 20 requests can be initiated per second for this API.
The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| Action | Yes | String | Common Params. The value used for this API: SearchLog. |
| Version | Yes | String | Common Params. The value used for this API: 2019-09-04. |
| Region | No | String | Common Params. This parameter is not required for this API. |
| From | Yes | Integer | Start time for logs to be searched and analyzed, which is a Unix timestamp in milliseconds |
| To | Yes | Integer | End time for logs to be searched and analyzed, which is a Unix timestamp in milliseconds |
| Query | Yes | String | The retrieval and analysis statement has a maximum length of 12 KB. |
| SyntaxRule | No | Integer | Search syntax rules. Default value is 0. Recommended for use is 1.
For details, see Retrieval condition syntax rules |
| TopicId | No | String |
|
| Topics.N | No | Array of MultiTopicSearchInformation |
|
| Sort | No | String | Whether raw logs are returned in time sequence; value range: asc (ascending), desc (descending), default is desc
|
| Limit | No | Integer | Number of raw logs returned in a single query. Default value: 100. Maximum value: 1000.
You can retrieve more logs in two ways:
|
| Offset | No | Integer | Query the offset of raw logs, indicating the line number from which to start returning raw logs. Default value is 0.
|
| Context | No | String | Pass the Context value returned by the last API call to obtain more logs later. The total number of raw logs that can be obtained is up to 10,000 entries. The expiration time is 1 hour.
|
| SamplingRate | No | Float | When performing statistical analysis (SQL included in Query), whether to sample raw logs first and then perform statistical analysis. |
| UseNewAnalysis | No | Boolean | true means using the new retrieval result return method, and output parameters AnalysisRecords and Columns are valid. |
| Parameter Name | Type | Description |
|---|---|---|
| Context | String | Pass through the Context value returned by this API to obtain more logs later. The expiration time is 1 hour.
|
| ListOver | Boolean | Whether all logs meeting the retrieval criteria have been returned. If not, use Context parameter to retrieve more logs. |
| Analysis | Boolean | Whether the returned data is the SQL analysis result |
| Results | Array of LogInfo | Raw logs matching the retrieval criteria Note: This field may return null, indicating that no valid values can be obtained. |
| ColNames | Array of String | Column names of log statistics analysis results Note: This field may return null, indicating that no valid values can be obtained. |
| AnalysisResults | Array of LogItems | Log statistics and analysis results Note: This field may return null, indicating that no valid values can be obtained. |
| AnalysisRecords | Array of String | Log statistics and analysis results Note: This field may return null, indicating that no valid values can be obtained. |
| Columns | Array of Column | Column attribute of the statistical analysis result Note: This field may return null, indicating that no valid values can be obtained. |
| SamplingRate | Float | Sampling rate used for this statistical analysis Note: This field may return null, indicating that no valid values can be obtained. |
| Topics | SearchLogTopics | When multiple log topics are used for retrieval, basic information of each log topic, such as error message. Note: This field may return null, indicating that no valid values can be obtained. |
| RequestId | String | The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem. |
Query logs with the HTTP protocol
POST / HTTP/1.1
Host: cls.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: SearchLog
<Common request parameters>
{
"TopicId": "cfw_netflow_border",
"From": 1782131614167,
"To": 1782736414167,
"Query": "protocol:HTTP",
"SamplingRate": 1,
"SyntaxRule": 1,
"Limit": 1,
"Context": "",
"Sort": "desc",
"UseNewAnalysis": true
}
{
"Response": {
"Analysis": false,
"Context": "Y29udGV4dC0wMmUyNmVmYi05OTZiLTQzNTctYTA1Ny03OGY1NmU3ZmRmNzUxNzgyNzM2NDc1NzE5",
"ListOver": false,
"RequestId": "e660b374-1538-4631-be77-c9a6e6680180",
"Results": [
{
"FileName": "",
"LogJson": "{\"instance_id\":\"ins-gke2r5e0\",\"src_ip\":\"119.**.**.112\",\"dst_ip\":\"103.**.**.115\",\"src_port\":56980,\"dst_port\":80,\"protocol\":\"HTTP\",\"direction\":0,\"dst_domain\":\"www.**.com\",\"in_pkt_count\":8,\"in_pkt_len\":2998,\"out_pkt_count\":8,\"out_pkt_len\":416,\"total_pkt_count\":16,\"total_pkt_len\":3414,\"ti_tag\":\"\",\"start_time\":\"2026-06-29 14:12:11\",\"end_time\":\"2026-06-29 14:12:24\",\"supplier\":\"baidu.com\",\"src_country\":\"\",\"dst_country\":\"China\",\"src_province\":\"\",\"dst_province\":\"Guangdong Province\",\"src_city\":\"\",\"dst_city\":\"\",\"address\":\"Guangdong Province\",\"src_lat\":0,\"dst_lat\":0,\"src_lon\":0,\"dst_lon\":0,\"insert_time\":1782713553,\"count\":0,\"url\":\"\",\"domain_flag\":0,\"port_status\":0,\"level\":0,\"bot_flag\":0,\"mode\":1,\"tcp_flag\":31,\"timestamp\":\"2026-06-29 14:12:11\",\"is_serial\":1,\"pkt_flags\":\"0212101810\",\"pkt_dir\":\"01001\",\"action_src\":1,\"acl_uuid\":\"\",\"acl_rule_id\":0,\"acl_detail\":\"\"}"
"PkgId": "5229A51C7BECDA416A3E478F-00000000000579C7",
"PkgLogId": "29622640",
"RawLog": "",
"Time": 1782713531000,
"TopicId": "cfw_netflow_border"
}
],
"SamplingRate": 0
}
}
TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.
The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.
| Error Code | Description |
|---|---|
| FailedOperation | Operation failed. |
| FailedOperation.InvalidContext | FailedOperation.InvalidContext |
| FailedOperation.QueryError | FailedOperation.QueryError |
| FailedOperation.SearchTimeout | FailedOperation.SearchTimeout |
| FailedOperation.SyntaxError | FailedOperation.SyntaxError |
| FailedOperation.Timeout | FailedOperation.Timeout |
| FailedOperation.TopicIsolated | FailedOperation.TopicIsolated |
| InternalError | Internal error. |
| InternalError.SearchError | InternalError.SearchError |
| InternalError.SearchFailed | InternalError.SearchFailed |
| InternalError.ServerBusy | InternalError.ServerBusy |
| InvalidParameter | Invalid parameter. |
| LimitExceeded.LogSearch | LimitExceeded.LogSearch |
| LimitExceeded.SearchResources | LimitExceeded.SearchResources |
| LimitExceeded.SearchResultTooLarge | LimitExceeded.SearchResultTooLarge |
| MissingParameter | Missing parameter. |
| OperationDenied | Operation denied. |
| OperationDenied.AccountDestroy | OperationDenied.AccountDestroy |
| OperationDenied.AccountIsolate | OperationDenied.AccountIsolate |
| OperationDenied.AccountNotExists | OperationDenied.AccountNotExists |
| OperationDenied.NewSyntaxNotSupported | OperationDenied.NewSyntaxNotSupported |
| OperationDenied.OperationNotSupportInSearchLow | OperationDenied.OperationNotSupportInSearchLow |
| ResourceNotFound.TopicNotExist | ResourceNotFound.TopicNotExist |
피드백