Date: 2022-11-02
Sourcegraph has lacked first-class support for audit logging until now. This ADR doesn't intend to explain the business decisions behind building an audit log but the technical solution. For reading more about the business context, refer to the following RFCs:
For using and configuring the audit log, refer to the Docs page
Add easy-to-use audit logging API, available in internal/audit/audit.go. The API entry point is the audit.Log function.
- Audit logs are regular structured logs that carry additional information in the
Attributesmap. - Audit data is available in the
Attributes.auditproperty. - Any additional audit-related context is a direct child of the
Attributesproperty. - Audit logs are "immune" to sampling (they never get dropped); this is achieved using a unique message in the
Bodyproperty (which carries a generatedauditIdUUID).
Audit log entries are now a part of the standard log output.
- On-premises installation may filter them from the stdout, looking for
Attributes.auditorauditIdproperties. - Cloud instances will ship with first-class support (TBD).