数据库审计
数据库审计¶
数据库审计功能主要用途有两方面:
- 记录用户的操作
- 记录资源使用
使用审计日志的前提是开启csv日志功能和开启日志归档功能 这部分参考数据库日志管理章节的日志推荐配置和日志归档功能
审计日志¶
-
审计日志还是保留如下兼容历史版本的视图,更多审计日志内容参考数据库日志管理章节的日志记录内容部分和内置审计功能部分
-
sdlog.vw_audit
列名 | 类型 | 说明 |
---|---|---|
db_id | smallint | 用于区分coordinator |
session_id | text | 用于区分session |
session_line_num | numeric | 在该session执行的sql的行号 |
log_time | timestamptz(3) | 日志时间 |
user_name | text | 登陆用户名 |
connection_from | text | 从何处进行的连接 |
connection_to | text | 登陆到何处 |
statement_id | numeric | 当前session的sql编号 |
state | text | ok/error |
error_session_line_num | numeric | 执行失败的sql的位置 |
substatement_id | numeric | 当前sql的子sql编号 |
substatement | text | 子sql语句 |
row | numeric | 结果行数 |
audit_type | text | session(主体操作)/objcect(客体操作) |
class | text | 分类,如read |
command | text | 命令,如select |
object_type | text | 客体类型,audit_type是session时为空 |
object_name | text | 客体名称,audit_type是session时为空 |
- sdlog.vw_audit_event
列名 | 类型 | 说明 |
---|---|---|
db_id | smallint | 用于区分coordinator |
session_id | text | 用于区分session |
session_line_num | numeric | 在该session执行的sql的行号 |
log_time | timestamptz(3) | 日志时间 |
user_name | text | 登陆用户名 |
connection_from | text | 从何处进行的连接 |
connection_to | text | 登陆到何处 |
statement_id | numeric | 当前session的sql编号 |
state | text | ok/error |
error_session_line_num | numeric | 执行失败的sql的位置 |
substatement_id | numeric | 当前sql的子sql编号 |
substatement | text | 子sql语句 |
row | numeric | 结果行数 |
audit_type | text | session(主体操作)/objcect(客体操作) |
class | text | 分类,如read |
command | text | 命令,如select |
object_type | text | 客体类型,audit_type是session时为空 |
object_name | text | 客体名称,audit_type是session时为空 |