MM-23222 mirror audit logs to file (#14062)

* MM-23222 add file target (with rotation) to audit

* MM-23222 mirror syslog audits to local filesystem

    * provides config options for file name, max size, max age

    * rotates files based on max size and max age; delete as needed based on max backups

* include cluster id in log records

* sort meta data fields
Этот коммит содержится в:
Doug Lauder
2020-03-17 16:12:56 -04:00
коммит произвёл GitHub
родитель 1cde88f147
Коммит 16b535314d
33 изменённых файлов: 570 добавлений и 816 удалений

Просмотреть файл

@@ -42,22 +42,10 @@ func (c *Context) LogAuditRecWithLevel(rec *audit.Record, level audit.Level) {
}
rec.Fail()
}
c.App.Srv().Audit.LogRecord(level, *rec)
}
// LogAuditMeta creates an audit record and logs it.
func (c *Context) LogAuditEx(event string, status string) {
rec := c.MakeAuditRecord(event, status)
c.LogAuditRec(rec)
}
// LogAuditMeta creates an audit record with metadata and logs it.
func (c *Context) LogAuditMeta(event string, status string, meta audit.Meta) {
rec := c.MakeAuditRecord(event, status)
if meta != nil {
rec.Meta = meta
if cid := c.App.GetClusterId(); cid != "" {
rec.AddMeta(audit.KeyClusterID, cid)
}
c.LogAuditRec(rec)
c.App.Srv().Audit.LogRecord(level, *rec)
}
// MakeAuditRecord creates a audit record pre-populated with data from this context.