|
2 | 2 | title: System History Tables |
3 | 3 | --- |
4 | 4 |
|
5 | | -import FunctionDescription from '@site/src/components/FunctionDescription'; |
| 5 | +import EEFeature from '@site/src/components/EEFeature'; |
6 | 6 |
|
7 | | -<FunctionDescription description="Introduced or updated: v1.2.752"/> |
| 7 | +<EEFeature featureName='SYSTEM HISTORY'/> |
8 | 8 |
|
9 | 9 | # System History Tables |
10 | 10 |
|
11 | | -System history tables store persistent data in the `system_history` schema for auditing, troubleshooting, and compliance purposes. They track query execution, user logins, and system logs that can be queried using standard SQL. |
| 11 | +Databend's system history tables provide **Data Governance** capabilities by automatically tracking database activities for compliance, security monitoring, and performance analysis. |
12 | 12 |
|
13 | | -## Available System History Tables |
| 13 | +## Available Tables |
14 | 14 |
|
15 | | -| Table | Description | |
16 | | -|-----------------------------------------------------|-----------------------------------------------------------------| |
17 | | -| [system_history.log_history](log-history.md) | Stores raw log entries from various system components. | |
18 | | -| [system_history.query_history](query-history.md) | Stores structured details of query execution. | |
19 | | -| [system_history.profile_history](profile-history.md)| Stores detailed query execution profiles and statistics. | |
20 | | -| [system_history.login_history](login-history.md) | Records information about user login events. | |
21 | | -| [system_history.access_history](access-history.md) | Stores information about query access events. | |
| 15 | +| Table | Purpose | Key Use Cases | |
| 16 | +|-------|---------|---------------| |
| 17 | +| [query_history](query-history.md) | Complete SQL execution audit trail | Performance analysis, compliance tracking, usage monitoring | |
| 18 | +| [access_history](access-history.md) | Data access and modification logs | Data lineage, compliance reporting, change management | |
| 19 | +| [login_history](login-history.md) | User authentication tracking | Security auditing, failed login monitoring, access pattern analysis | |
| 20 | +| [profile_history](profile-history.md) | Detailed query execution profiles | Performance optimization, resource planning, bottleneck identification | |
| 21 | +| [log_history](log-history.md) | Raw system logs and events | System troubleshooting, error analysis, operational monitoring | |
22 | 22 |
|
23 | | -## Enabling System History Tables |
| 23 | +## Configuration |
24 | 24 |
|
25 | | -> **Note:** In **Databend Cloud**, system history tables are automatically enabled and ready to use without any configuration needed. The following section applies only to **self-hosted Databend**. |
| 25 | +### Databend Cloud |
| 26 | +✅ **Automatically enabled** - All system history tables are ready to use without any configuration. |
26 | 27 |
|
27 | | -In self-hosted Databend, system history tables are disabled by default. To enable them, configure the `[log.history]` section in your `databend-query.toml` file. |
| 28 | +### Self-Hosted Databend |
28 | 29 |
|
29 | | -Configuration Example: |
| 30 | +<details> |
| 31 | +<summary>📝 **Manual configuration required** - Click to expand configuration details</summary> |
| 32 | + |
| 33 | +#### Minimal Configuration |
| 34 | +To enable system history tables, you must configure all 5 tables in your `databend-query.toml`: |
30 | 35 |
|
31 | 36 | ```toml |
32 | 37 | [log.history] |
33 | | -# Enable history tables |
34 | 38 | on = true |
35 | | -level = "INFO" |
36 | 39 |
|
37 | | -# Configure retention policies for each table |
| 40 | +# All 5 tables must be configured to enable history logging |
| 41 | +# retention is optional (default: 168 hours = 7 days) |
38 | 42 | [[log.history.tables]] |
39 | | -table_name = "log_history" |
40 | | -retention = 168 # 7 days (in hours) |
| 43 | +table_name = "query_history" |
| 44 | +retention = 168 # Optional: 7 days (default) |
41 | 45 |
|
42 | 46 | [[log.history.tables]] |
43 | | -table_name = "query_history" |
44 | | -retention = 168 |
| 47 | +table_name = "login_history" |
| 48 | +retention = 168 # Optional: 7 days (default) |
| 49 | + |
| 50 | +[[log.history.tables]] |
| 51 | +table_name = "access_history" |
| 52 | +retention = 168 # Optional: 7 days (default) |
45 | 53 |
|
46 | 54 | [[log.history.tables]] |
47 | 55 | table_name = "profile_history" |
48 | | -retention = 168 |
| 56 | +retention = 168 # Optional: 7 days (default) |
49 | 57 |
|
50 | 58 | [[log.history.tables]] |
51 | | -table_name = "login_history" |
52 | | -retention = 168 |
| 59 | +table_name = "log_history" |
| 60 | +retention = 168 # Optional: 7 days (default) |
| 61 | +``` |
| 62 | + |
| 63 | +#### Custom Storage (Optional) |
| 64 | +By default, history tables use your main database storage. To use separate S3 storage: |
| 65 | + |
| 66 | +```toml |
| 67 | +[log.history] |
| 68 | +on = true |
| 69 | + |
| 70 | +[log.history.storage] |
| 71 | +type = "s3" |
| 72 | + |
| 73 | +[log.history.storage.s3] |
| 74 | +bucket = "your-history-bucket" |
| 75 | +root = "history_tables" |
| 76 | +endpoint_url = "https://s3.amazonaws.com" |
| 77 | +access_key_id = "your-access-key" |
| 78 | +secret_access_key = "your-secret-key" |
53 | 79 | ``` |
54 | 80 |
|
55 | | -> **Note:** The `log_history` table is enabled by default when history logging is turned on. The `level` configuration determines the number of log entries stored in the log_history table. A more detailed level will result in more entries. |
| 81 | +> ⚠️ **Note:** When changing storage configuration, existing history tables will be dropped and recreated. |
56 | 82 |
|
| 83 | +</details> |
57 | 84 |
|
58 | | -For more details about configuration options, see [Query Configuration: [log.history] Section](/guides/deploy/references/node-config/query-config#loghistory-section). |
| 85 | +For complete configuration options, see [Query Configuration: [log.history] Section](/guides/deploy/references/node-config/query-config#loghistory-section). |
0 commit comments