Skip to main content

Audit and Compliance

ENTERPRISE FEATURE

The features or components discussed in this document are available in TDengine TSDB-Enterprise only. TDengine TSDB-OSS does not include these features or components.

TDengine records user operations and sends them to taosKeeper, which stores the audit logs in a TDengine cluster. Starting with v3.4.1.0, audit records can instead be stored in the local cluster by enabling auditSaveInSelf. For authoritative parameter details, see taosd.

In this document, “compliance” means supporting internal audits and operational traceability with configurable audit trails, and applying fixes published in Security Advisories. It does not claim compliance with a specific external certification or regulation.

Audit Logs

TDengine first records and manages user operations, then sends these as audit logs to taosKeeper, which then saves them to any TDengine cluster. Administrators can use audit logs for security monitoring and historical tracing. Enabling and disabling TDengine's audit log feature is very simple, just modify the TDengine configuration file and restart the service. The configuration details for audit logs are as follows.

taosd Configuration

Audit logs are generated by the database service taosd, and its relevant parameters need to be configured in the taos.cfg configuration file, detailed parameters are as follows.

Parameter NameParameter Meaning
auditWhether to enable audit logs. Enterprise default: 1; 1 enables and 0 disables auditing
monitorFqdnFQDN of the taosKeeper server receiving audit logs
monitorPortPort of the taosKeeper service receiving audit logs
monitorCompactionWhether to compress data during reporting
auditLevelAudit level controlling which operations are recorded. Default 3 (database level), starting with v3.4.0.0
auditHttpsWhether to use HTTPS when sending audit records to taosKeeper. Default 0, starting with v3.4.0.0
auditUseTokenWhether to authenticate reports with a token. Default 1, starting with v3.4.0.0
auditCreateTableWhether to audit child-table creation. Default 1
auditSaveInSelfWhether to store audit records in the local cluster instead of sending them to taosKeeper. Default 0, starting with v3.4.1.0

For types, ranges, and dynamic-modification support, see the taosd reference.

create audit database

Audit database need to be created after audit is set, and parameter is_audit need to be set.

CREATE DATABASE [IF NOT EXISTS] db_name [database_options] IS_AUDIT 1;

database_options:
database_option ...

database_option: {
DURATION value
}

database_option: {
WAL_LEVEL value
}

database_option: {
ENCRYPT_ALGORITHM value
}

Additionally, for an audit database:

  • The default value for keep is 1825 days. If a user specifies keep, it must be greater than 1825 days.
  • WAL_LEVEL defaults to 2 and cannot be changed by the user.
  • ENCRYPT_ALGORITHM cannot be specified as None. The user can choose any symmetric encryption algorithm in CBC mode.
  • PRECISION defaults to nanosecond (ns) and cannot be changed to other precisions.

Audit databases created before v3.4.0.0 are incompatible with audit features in v3.4.0.0 and later. In older versions, the is_audit parameter was not enforced, so there were no mandatory requirements for DURATION, WAL_LEVEL, and ENCRYPT_ALGORITHM. To enable new audit features for an old audit database, it must be dropped and recreated. As a workaround to access data from a pre-v3.4.0.0 audit database in a newer version (without new audit features), you can disable auditUseToken by setting it to 0.

In v3.4.1.0 and later, audit information can be saved locally rather than sent to taosKeeper. To use this functionality, set auditSaveInSelf to 1; the audit database must have exactly one vgroup.

taosKeeper Configuration

Configure the related parameters for audit logs in the taosKeeper configuration file keeper.toml, as shown in the table below

Parameter NameDescription
auditDBThe name of the database used to store audit logs, default is "audit". taosKeeper will check if this database exists upon receiving audit logs, and will create it automatically if it does not exist.

Data Format

The format of the reported audit logs is as follows

{
"ts": timestamp,
"cluster_id": string,
"user": string,
"operation": string,
"db": string,
"resource": string,
"client_add": string,
"details": string,
"affected_rows": integer,
"duration": double
}

Table Structure

taosKeeper will automatically create a supertable in the corresponding database based on the reported audit data to store the data. The definition of this supertable is as follows:

create stable operations (ts timestamp, user_name varchar(25), operation varchar(20), db varchar(65), resource varchar(193), client_address varchar(64), details varchar(50000)) tags (cluster_id varchar(64))

Where:

  1. db refers to the database involved in the operation, resource refers to the resource involved.
  2. user_name and operation are data columns, indicating which user performed what operation on the object.
  3. ts is the timestamp column, indicating the time when the operation occurred.
  4. details provide additional details of the operation, which in most cases is the SQL statement executed.
  5. client_address is the client address, including IP and port.

Operation List

The current list of operations recorded in the audit logs and the meanings of each field in each operation are shown in the table below (Note: since the user field, timestamp, and client_add have the same meaning in all operations, they are not included in the table below)

auditLevel = 1 // AUDIT_LEVEL_SYSTEM

OperationOperationDBResourceDetails
create dnodecreateDnodeNULLIP:Port or FQDN:PortSQL
drop dnodedropDnodeNULLdnodeIdSQL
alter dnodealterDnodeNULLdnodeIdSQL
create mnodecreateMnodeNULLdnodeIdSQL
drop mnodedropMnodeNULLdnodeIdSQL
create qnodecreateQnodeNULLdnodeIdSQL
drop qnodedropQnodeNULLdnodeIdSQL
restore dnoderestoreDnodeNULLdnodeIdSQL

auditLevel = 2 // AUDIT_LEVEL_CLUSTER

OperationOperationDBResourceDetails
alter clusteralterClusterNULLNULLSQL
balance vgroup leaderbalanceVgroupLeadNULLNULLSQL
redistribute vgroupredistributeVgroupNULLvgroupIdSQL
balance vgroupbalanceVgroupNULLvgroupIdSQL
assign leaderassignLeaderNULLNULLSQL
grant privilegesgrantPrivilegesNULLuser grantedSQL
revoke privilegesrevokePrivilegesNULLuser whose privileges were revokedSQL
loginloginNULLNULLappName
create usercreateUserNULLusername being createdUser attribute parameters, (excluding password)
alter useralterUserNULLusername being modifiedPassword change logs the modified parameters and new values (excluding password); other operations log SQL
drop userdropUserNULLusername being deletedSQL
create mountcreateMountmountNameNULLSQL
drop mountdropMountmountNameNULLSQL
kill retentionkillRetentiondb nameNULLSQL
auto trimDBautoTrimDBdb nameNULLSQL
create encrypt algrcreateEncryptAlgrNULLalgorithmIdSQL
drop encrypt algrdropEncryptAlgrNULLalgorithmIdSQL

auditLevel = 3 // AUDIT_LEVEL_DATABASE

OperationOperationDBResourceDetails
create databasecreateDBdb nameNULLSQL
alter databasealterDBdb nameNULLSQL
drop databasedropDBdb nameNULLSQL
compact databasecompactdatabase nameNULLSQL
kill compactkillCompactdb nameNULLSQL
create stablecreateStbdb namestable nameSQL
alter stablealterStbdb namestable nameSQL
drop stabledropStbdb namestable nameSQL
create streamcreateStreamNULLname of the created streamSQL
drop streamdropStreamNULLname of the deleted streamSQL
recalc streamrecalcStreamstreamNamerecalcNameSQL
create topiccreateTopictopic's DBname of the created topicSQL
drop topicdropTopictopic's DBname of the deleted topicSQL
reload topicreloadTopictopic's DBname of the topicSQL
create RsmacreateRsmaRsma nameNULLSQL
alter RsmaalterRsmaRsma nameTable nameSQL
drop RsmadropRsmaRsma nameNULLSQL
create ViewcreateViewDb nameNULLSQL
drop ViewdropViewDb nameview nameSQL

auditLevel = 4 // AUDIT_LEVEL_CHILDTABLE

OperationOperationDBResourceDetails
create tablecreateTabledb nametable nameSQL
drop tabledropTabledb nametable nameSQL

View Audit Logs

After both taosd and taosKeeper are correctly configured and started, as the system continues to operate, various operations (as shown in the table above) will be recorded and reported in real-time. Users can log in to taosExplorer, click on "System Management" > "Audit" page to view the audit logs; they can also directly query the relevant databases and tables in the TDengine CLI.

Security Advisories and Vulnerability Disclosure

Known security vulnerabilities, affected versions, and fixes are published on Security Advisories. If you discover an undisclosed vulnerability, report it privately using the channels on that page; do not discuss unfixed issues in public forums or issues.

For hardening and deployment guidance, see Security Deployment Suggestions.