tencent cloud

APIs

DescribeAuditLogs

下载
聚焦模式
字号
最后更新时间: 2026-10-23 11:27:11

1. API Description

Domain name for API request: cynosdb.intl.tencentcloudapi.com.

This API is used to query database audit logs.

A maximum of 20 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

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: DescribeAuditLogs.
Version Yes String Common Params. The value used for this API: 2019-01-07.
Region Yes String Common Params. For more information, please see the list of regions supported by the product.
InstanceId Yes String Instance ID.
StartTime Yes String Start time in the format of "2017-07-12 10:29:20".
EndTime Yes String End time in the format: "2017-07-12 10:29:20".
Order No String Sort order. Supported values: "ASC" - Ascending order, "DESC" - Descending order.
OrderBy No String Sorting field. Supported values include:
timestamp
"affectRows" - Number of affected rows
"execTime" - Execution time.
Limit No Integer Pagination parameter. Number of data entries returned per request. Default value: 100. Maximum value: 100.
Offset No Integer Pagination offset.
Description: The sum of Limit and Offset must be less than or equal to 65536.
LogFilter.N No Array of InstanceAuditLogFilter Filter criteria. Multiple values have an AND relationship.

3. Output Parameters

Parameter Name Type Description
TotalCount Integer Number of eligible audit log entries.
Items Array of AuditLog Audit log details.
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.

4. Example

Example1 Query records within the xx time range where the sql contains select and test_db, and the source IP is not equal to 10.0.0.1 and not equal to 100.0.0.1

Input Example

POST / HTTP/1.1
Host: cynosdb.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: DescribeAuditLogs
<Common request parameters>

{
    "InstanceId": "cynosdbmysql-ins-qwerasdf",
    "StartTime": "2023-08-01 00:00:00",
    "EndTime": "2023-08-07 00:00:00",
    "Limit": 20,
    "LogFilter": [
        {
            "Type": "sql",
            "Compare": "WINC",
            "Value": [
                "select"
            ]
        },
        {
            "Type": "sql",
            "Compare": "WINC",
            "Value": [
                "test_db"
            ]
        },
        {
            "Type": "host",
            "Compare": "NEQ",
            "Value": [
                "10.0.0.1",
                "100.0.0.1"
            ]
        }
    ]
}

Output Example

{
    "Response": {
        "Items": null,
        "RequestId": "90d90456-2a5b-4015-81b8-9e2fca52012b",
        "TotalCount": 0
    }
}

Example2 Query records within the xx time range where the sql contains selec or upda and the source IP address contains 10.0.

sql sample: select * from test_db limit 1;
sql INC SELECT can search for results.
Unable to find a sample for sql WINC select.

Input Example

POST / HTTP/1.1
Host: cynosdb.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: DescribeAuditLogs
<Common request parameters>

{
    "InstanceId": "cynosdbmysql-ins-qwerasdf",
    "StartTime": "2023-08-01 00:00:00",
    "EndTime": "2023-08-07 00:00:00",
    "Limit": 20,
    "LogFilter": [
        {
            "Type": "sql",
            "Compare": "INC",
            "Value": [
                "selec",
                "up"
            ]
        },
        {
            "Type": "host",
            "Compare": "INC",
            "Value": [
                "10.0."
            ]
        }
    ]
}

Output Example

{
    "Response": {
        "Items": null,
        "RequestId": "90d90456-2a5b-4015-81b8-9e2fca52012b",
        "TotalCount": 0
    }
}

Example3 This API is used to query an audit log.

This API is used to query an audit log.

Input Example

POST / HTTP/1.1
Host: cynosdb.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: DescribeAuditLogs
<Common request parameters>

{
    "InstanceId": "cynosdbmysql-ins-qwerasdf",
    "StartTime": "2017-07-12 10:29:20",
    "EndTime": "2017-07-13 10:29:20"
}

Output Example

{
    "Response": {
        "RequestId": "6EF60BEC-0242-43AF-BB20-270359FB54A7",
        "TotalCount": 1,
        "Items": [
            {
                "PolicyName": "sys_default",
                "ExecTime": 0,
                "Timestamp": "2023-06-26 10:32:36.000",
                "AffectRows": 0,
                "ThreadId": 0,
                "TableName": "",
                "ErrCode": 0,
                "Host": "10.0.0.1",
                "SentRows": 0,
                "User": "andy",
                "Sql": "SELECT * FROM test LIMIT 1;",
                "SqlType": "SELECT",
                "InstanceName": "cynosdbandy",
                "DBName": "db1"
            }
        ]
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

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.DatabaseAccessError Database access failed. Try again later. If the issue persists, contact customer service.
FailedOperation.ServiceAccessError Log query failed. Narrow down the query range. If the issue persists, contact customer service.
InternalError.HttpError Network error.
InternalError.ListInstancesError Query instance error
InvalidParameter.ExceptionParam Parameter error.
InvalidParameter.InvalidParameterError Unknown parameter. Check whether the parameter is valid.
InvalidParameterValue.InvalidParameterValueError Parameter value is invalid.

帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈