Domain name for API request: cls.tencentcloudapi.com.
This API is used to search logs. It is subject to the default API rate limit, and the number of concurrent queries to the same log topic cannot exceed 15.
A maximum of 10000 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: 2020-10-16. |
Region | Yes | String | Common Params. For more information, please see the list of regions supported by the product. |
TopicId | Yes | String | ID of the log topic to be searched |
From | Yes | Integer | Start time of the log to be searched, which is a Unix timestamp in milliseconds |
To | Yes | Integer | End time of the log to be searched, which is a Unix timestamp in milliseconds |
Query | Yes | String | Statement for search and analysis. Maximum length: 12 KB A statement is in the format of [search rule] | [SQL statement]. You can omit the pipe symbol | and SQL statement when log analysis is not required. |
Limit | No | Integer | The number of raw logs returned by a single query. Maximum value: 1000. You need to use Context to continue to get logs.Notes: * This parameter is valid only when the query statement ( Query ) does not contain an SQL statement.* To limit the number of analysis results, see SQL LIMIT Syntax. |
Context | No | String | You can pass through the Context value (validity: 1 hour) returned by the last API to continue to get logs, which can get up to 10,000 raw logs.Notes: * This parameter is valid only when the query statement ( Query ) does not contain an SQL statement.* To continue to get analysis results, see SQL LIMIT Syntax. |
Sort | No | String | Time order of the logs returned. Valid values: asc (ascending); desc : (descending). Default value: desc Notes: * This parameter is valid only when the query statement ( Query ) does not contain an SQL statement.* To sort the analysis results, see SQL ORDER BY Syntax. |
UseNewAnalysis | No | Boolean | If the value is true , the new response method will be used, and the output parameters AnalysisRecords and Columns will be valid.If the value is false , the old response method will be used, and the output parameters AnalysisResults and ColNames will be valid.The two response methods differ slightly in terms of encoding format. You are advised to use the new method ( true ). |
Parameter Name | Type | Description |
---|---|---|
Context | String | You can pass through the Context value (validity: 1 hour) returned by this API to continue to get more logs. |
ListOver | Boolean | Whether to return all raw log query results. If not, you can use Context to continue to get logs.Note: This parameter is valid only when the query statement ( Query ) does not contain an SQL statement. |
Analysis | Boolean | Whether the returned data is the analysis (SQL) result |
Results | Array of LogInfo | Raw logs that meet the search conditions Note: This field may return null , indicating that no valid value was found. |
ColNames | Array of String | Column names of log analysis This parameter is valid only when UseNewAnalysis is false .Note: This field may return null , indicating that no valid value was found. |
AnalysisResults | Array of LogItems | Log analysis result This parameter is valid only when UseNewAnalysis is false .Note: This field may return null , indicating that no valid value was found. |
AnalysisRecords | Array of String | Log analysis result This parameter is valid only when UseNewAnalysis is true .Note: This field may return null , indicating that no valid value was found. |
Columns | Array of Column | Column attributes of log analysis This parameter is valid only when UseNewAnalysis is true .Note: This field may return null , indicating that no valid value was found. |
RequestId | String | The unique request ID, which is returned for each request. RequestId is required for locating a problem. |
POST / HTTP/1.1
Host: cls.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: SearchLog
<Common request parameters>
{
"TopicId": "682d0718-07bb-4ec0-9fda-f1e9a2767e0b",
"From": 1608794854000,
"To": 1608794855000,
"Query": "http_status:200",
"Limit": 100
}
{
"Response": {
"AnalysisRecords": [
"xx"
],
"Results": [
{
"PkgId": "xx",
"TopicId": "xx",
"FileName": "xx",
"Source": "xx",
"LogJson": "xx",
"Time": 1608794854001,
"TopicName": "xx",
"PkgLogId": "xx"
}
],
"Analysis": false,
"ListOver": true,
"Context": "xx",
"AnalysisResults": [
{
"Data": [
{
"Value": "xx",
"Key": "xx"
}
]
}
],
"ColNames": [
"xx"
],
"Columns": [
{
"Type": "xx",
"Name": "xx"
}
],
"RequestId": "xx"
}
}
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 | The search cursor is invalid or does not exist. |
FailedOperation.QueryError | The query statement failed to run. |
FailedOperation.SearchTimeout | The query timed out. |
FailedOperation.SyntaxError | An error occurred while parsing the query statement. |
FailedOperation.TopicIsolated | The log topic has been isolated. |
InternalError | Internal error. |
InvalidParameter | Incorrect parameter. |
LimitExceeded.LogSearch | The number of concurrent queries exceeds the limit, which is 15 per topic. |
LimitExceeded.SearchResultTooLarge | The number of logs returned by the search API exceeds the upper limit (20 MB). |
MissingParameter | Missing parameter. |
OperationDenied | Operation denied. |
OperationDenied.AccountDestroy | The account has been terminated. |
OperationDenied.AccountIsolate | The account has overdue payments. |
OperationDenied.AccountNotExists | The account does not exist. |
OperationDenied.OperationNotSupportInSearchLow | The operation is not supported in IA storage. |
ResourceNotFound.TopicNotExist | The log topic does not exist. |
Was this page helpful?