用途:通过 pscale audit-log 命令检查 PlanetScale 组织的审计事件,并下载经过筛选的数据库认证尝试导出归档,用于账号活动调查与安全分析。
主要能力:
- 列出组织审计事件,例如 pscale audit-log list --org <org> --format json。
- 导出认证尝试,例如 pscale audit-log auth-attempts download --org <org> --since 24h --outcome deny --export-format jsonl --output ./auth-attempts.zip。
- 支持导出格式 jsonl、csv、parquet;CLI 人类可读/CSV 输出默认生成 CSV,JSON 输出默认生成 JSONL。
- 支持筛选:outcome(allow、deny)、失败原因、来源 IP/CIDR、分支、用户名、启动数据库、后端路由(postgres、pgbouncer、unknown)。多数列表筛选可重复或使用逗号分隔;--username 可重复且逗号视为用户名的一部分。
时间窗口:必须二选一。使用 --since <duration>(如 24h、7d、2w)表示截至当前;或使用 --start-at <time> 搭配可选的排他性 --end-at <time>。命名值(now、today、yesterday)与无时区时间戳按本地时区处理,API 请求会归一化为 UTC;跨主机可重复自动化时建议使用带显式偏移的 RFC3339 时间戳。
使用方式:命令会创建导出、等待就绪并下载 ZIP 归档。示例:pscale audit-log auth-attempts download --org <org> --start-at 2026-08-10T00:00:00Z --end-at 2026-08-11T00:00:00Z --outcome deny --failure-reason bad_password --export-format csv --output ./denied-auth-attempts.zip;也可用 --branch、--source-ip、--backend-route 缩小范围。
限制与安全:认证数据可能包含用户名、IP 地址和运营证据,只能写入经批准的路径,不要用 --output - 将原始 ZIP 字节打印到聊天或日志,仅通过批准渠道共享。请求大范围导出前应确认组织、时间区间与筛选条件。更多命令与参数见 references/commands.md。