Skip to content

TiDB Cloud Serverless database audit logging #20526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: release-8.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion TOC-tidb-cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@
- Database Access Control
- [Configure Cluster Password Settings](/tidb-cloud/configure-security-settings.md)
- Audit Management
- [Database Audit Logging](/tidb-cloud/tidb-cloud-auditing.md)
- [TiDB Cloud Dedicated Database Audit Logging](/tidb-cloud/tidb-cloud-auditing.md)
- [TiDB Cloud Serverless Database Audit Logging](/tidb-cloud//serverless-audit-logging.md)
- [Console Audit Logging](/tidb-cloud/tidb-cloud-console-auditing.md)
- Billing
- [Invoices](/tidb-cloud/tidb-cloud-billing.md#invoices)
Expand Down
76 changes: 76 additions & 0 deletions tidb-cloud/serverless-audit-logging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
title: TiDB Cloud Serverless Database Audit Logging
summary: Learn about how to audit a serverless cluster in TiDB Cloud.
---

# TiDB Cloud Serverless Database Audit Logging

TiDB Cloud Serverless provides you with a database audit logging feature to record a history of user access details (such as any SQL statements executed) in logs.

> **Note:**
>
> Currently, the database audit logging feature is only available upon request. To request this feature, click **?** in the lower-right corner of the [TiDB Cloud console](https://tidbcloud.com) and click **Request Support**. Then, fill in "Apply for TiDB Cloud Serverless database audit logging" in the **Description** field and click **Submit**.

To assess the effectiveness of user access policies and other information security measures of your organization, it is a security best practice to conduct a periodic analysis of the database audit logs.

The audit logging feature is disabled by default. To audit a cluster, you need to enable the audit logging.

## Enable audit logging

To enable the audit logging for a TiDB Cloud Serverless cluster, using the [TiDB Cloud CLI](/tidb-cloud/cli-reference.md)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding a link to the specific CLI command documentation for ticloud serverless audit-log enable for more detailed information.

Suggested change
To enable the audit logging for a TiDB Cloud Serverless cluster, using the [TiDB Cloud CLI](/tidb-cloud/cli-reference.md)
To enable the audit logging for a TiDB Cloud Serverless cluster, using the [TiDB Cloud CLI](/tidb-cloud/cli-reference.md#ticloud-serverless-audit-log-enable)


```shell
ticloud serverless audit-log enable --cluster-id <cluster-id>
```

To disable the audit logging for a TiDB Cloud Serverless cluster, using the [TiDB Cloud CLI](/tidb-cloud/cli-reference.md)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding a link to the specific CLI command documentation for ticloud serverless audit-log disable for more detailed information.

Suggested change
To disable the audit logging for a TiDB Cloud Serverless cluster, using the [TiDB Cloud CLI](/tidb-cloud/cli-reference.md)
To disable the audit logging for a TiDB Cloud Serverless cluster, using the [TiDB Cloud CLI](/tidb-cloud/cli-reference.md#ticloud-serverless-audit-log-disable)


```shell
ticloud serverless audit-log disable --cluster-id <cluster-id>
```

## Configure audit logging

### Redacted

TiDB Cloud Serverless redacts sensitive data in the audit logs by default. For example, the following SQL statement:

```sql
INSERT INTO `test`.`users` (`id`, `name`, `password`) VALUES (1, 'Alice', '123456');
```

is redacted as follows:

```sql
INSERT INTO `test`.`users` (`id`, `name`, `password`) VALUES ( ... );
```

If you want to disable the redaction, using the [TiDB Cloud CLI](/tidb-cloud/cli-reference.md)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding a link to the specific CLI command documentation for ticloud serverless audit-log config for more detailed information.

Suggested change
If you want to disable the redaction, using the [TiDB Cloud CLI](/tidb-cloud/cli-reference.md)
If you want to disable the redaction, using the [TiDB Cloud CLI](/tidb-cloud/cli-reference.md#ticloud-serverless-audit-log-config)


```shell
ticloud serverless audit-log config --cluster-id <cluster-id> --unredacted
```

### Rotation

TiDB Cloud Serverless will start to generate a new audit log file when one of the following conditions is met:

- The audit log file reaches 100 MB.
- The time interval reaches 1 hour. Note that the audit log files may not be generated exactly at the time interval of 1 hour, it may be delayed for a few minutes depending on the underlying schedule.

## View audit logs

TiDB Cloud Serverless audit logs are readable text files named `YYYY-MM-DD-<uuid>.log`. You can download the audit logs by [TiDB Cloud CLI](/tidb-cloud/cli-reference.md) to view them.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding a link to the specific CLI command documentation for ticloud serverless audit-log download for more detailed information.

Suggested change
TiDB Cloud Serverless audit logs are readable text files named `YYYY-MM-DD-<uuid>.log`. You can download the audit logs by [TiDB Cloud CLI](/tidb-cloud/cli-reference.md) to view them.
You can download the audit logs by [TiDB Cloud CLI](/tidb-cloud/cli-reference.md#ticloud-serverless-audit-log-download) to view them.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

It might be helpful to verify that this link is up to date and points to the correct location for the TiDB Cloud CLI documentation.


```shell
ticloud serverless audit-log download --cluster-id <cluster-id> --output-path <output-path> --start-day <start-day> --end-day <end-day>
```

> **Note:**
> TiDB Cloud only save your audit logs xx days.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This note is incomplete. Please fill in the number of days that TiDB Cloud saves audit logs. For example: TiDB Cloud only saves your audit logs for 90 days.

Suggested change
> TiDB Cloud only save your audit logs xx days.
> TiDB Cloud only saves your audit logs for XX days.


## Audit logging limitations

- The audit logging is only available for TiDB Cloud CLI, the support of TiDB Cloud Console will be available soon.

Check warning on line 74 in tidb-cloud/serverless-audit-logging.md

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [PingCAP.console] Use 'TiDB Cloud console' instead of 'TiDB Cloud Console'. Raw Output: {"message": "[PingCAP.console] Use 'TiDB Cloud console' instead of 'TiDB Cloud Console'.", "location": {"path": "tidb-cloud/serverless-audit-logging.md", "range": {"start": {"line": 74, "column": 74}}}, "severity": "INFO"}
- The audit logging can only be generated in the TiDB Cloud, the support of external storage will be available soon.
- TiDB Cloud Serverless does not guarantee the sequential order of the audit logs, which means you might have to review all log files to see the latest events. To order the logs, you can use the `TIME` field in the event records.
4 changes: 2 additions & 2 deletions tidb-cloud/tidb-cloud-auditing.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
title: Database Audit Logging
title: TiDB Cloud Dedicated Database Audit Logging
summary: Learn about how to audit a cluster in TiDB Cloud.
---

# Database Audit Logging
# TiDB Cloud Dedicated Database Audit Logging

TiDB Cloud provides you with a database audit logging feature to record a history of user access details (such as any SQL statements executed) in logs.

Expand Down