tencent cloud

AnalyzeAuditLogs
Last updated: 2024-11-20 11:15:34
AnalyzeAuditLogs
Last updated: 2024-11-20 11:15:34

1. API Description

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

This API is used to aggregate the audit logs filtered by different conditions and aggregate the statistics of the specified data rows.

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: AnalyzeAuditLogs.
Version Yes String Common Params. The value used for this API: 2017-03-20.
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 of the log to be analyzed in the format of 2023-02-16 00:00:20.
EndTime Yes String End time of the log to be analyzed in the format of 2023-02-16 00:00:20.
AggregationConditions.N Yes Array of AggregationCondition Sorting conditions for aggregation dimension
AuditLogFilter No AuditLogFilter This parameter is disused. The result set of the audit log filtered by this condition is set as the analysis log.
LogFilter.N No Array of InstanceAuditLogFilters The result set of the audit log filtered by this condition is set as the analysis Log.

3. Output Parameters

Parameter Name Type Description
Items Array of AuditLogAggregationResult Information set of the aggregation bucket returned
Note: This field may return null, indicating that no valid values can be obtained.
TotalCount Integer Number of scanned logs
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.

4. Example

Example1 Aggregating the statistics of an audit log

This example shows you how to aggregate the statistics of an audit log.

Input Example

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

{
    "InstanceId": "cdb-r9bpb9gs",
    "StartTime": "2023-02-16 00:00:20",
    "EndTime": "2023-02-16 00:10:20",
    "AggregationConditions": [
        {
            "AggregationField": "host",
            "Offset": 0,
            "Limit": 3
        },
        {
            "AggregationField": "sqlType",
            "Offset": 3,
            "Limit": 3
        }
    ]
}

Output Example

{
    "Response": {
        "Items": [
            {
                "AggregationField": "host"
            },
            {
                "AggregationField": "sqlType",
                "Buckets": [
                    {
                        "Count": 13,
                        "Key": "LOGOUT"
                    },
                    {
                        "Count": 5,
                        "Key": "CREATE"
                    },
                    {
                        "Count": 2,
                        "Key": "INSERT"
                    }
                ]
            }
        ],
        "RequestId": "0000000000000-00000-014",
        "TotalCount": 100
    }
}

Example2 Aggregating audit logs after filtering them

This example shows you how to aggregate audit logs after filtering them.

Input Example

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

{
    "InstanceId": "cdb-r9bpb9gs",
    "StartTime": "2023-02-16 00:00:00",
    "EndTime": "2023-02-17 00:00:00",
    "AuditLogFilter": {
        "SqlTypes": [
            "create"
        ]
    },
    "AggregationConditions": [
        {
            "AggregationField": "host",
            "Offset": 0,
            "Limit": 3
        }
    ]
}

Output Example

{
    "Response": {
        "Items": [
            {
                "AggregationField": "host",
                "Buckets": [
                    {
                        "Count": 3,
                        "Key": "100.122.76.176"
                    },
                    {
                        "Count": 2,
                        "Key": "9.71.156.179"
                    }
                ]
            }
        ],
        "RequestId": "0000000000000-00000-015",
        "TotalCount": 5
    }
}

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
InvalidParameter.ControllerNotFoundError This API was not found.
InvalidParameter.ExceptionParam Parameter exception.
InvalidParameter.InvalidParameterError Invalid parameter value
UnsupportedOperation Unsupported operation.
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback