Fixes #28770: write server audit entries to audit.log (#28771) [1.12.11]#28782
Conversation
Audit-to-file logging silently broke in #23733: gutting AuditEventHandler removed the only emitter of the AUDIT log marker, so the audit.log appender (audit-only-filter-factory) creates the file but never writes to it. Re-emit each audit entry through the AUDIT-marked logger from AuditLogRepository.write(), gated on a successful (non-duplicate) DB insert so the publisher+consumer dual-write path does not double-log. Emit a compact one-line summary at INFO rather than the full ChangeEvent JSON. Harden conf/openmetadata.yaml: pin the audit logger to INFO so capture is independent of LOG_LEVEL, and exclude audit lines from the console appender so they land only in audit.log. (cherry picked from commit 1a97633)
| org.openmetadata.service.audit.AuditLogRepository: | ||
| # Audit entries are logged at INFO with the AUDIT marker (see AuditLogger) and routed to | ||
| # logs/audit.log. Pin the level so audit capture does not depend on the global LOG_LEVEL. | ||
| level: INFO |
There was a problem hiding this comment.
💡 Quality: Pinning AuditLogRepository logger to INFO suppresses its DEBUG logs
The new org.openmetadata.service.audit.AuditLogRepository: level: INFO config pins the logger level so audit capture is independent of the global LOG_LEVEL. This is the intended behavior for audit capture, but a side effect is that the several LOG.debug(...) statements inside AuditLogRepository.write() (e.g. "Writing audit log for change event", "Inserting audit log record", "Successfully inserted audit log") will now be permanently suppressed even when an operator sets LOG_LEVEL=DEBUG to troubleshoot audit persistence. Since the same logger name is shared by both the @slf4j LOG instance and the AUDIT_LOGGER, the level pin cannot distinguish them. Consider documenting this trade-off, or routing the AUDIT marker emission through a dedicated logger name (e.g. a fixed "AUDIT" logger) pinned to INFO, leaving AuditLogRepository's own diagnostic logger free to follow the global level.
Was this helpful? React with 👍 / 👎
Code Review 👍 Approved with suggestions 0 resolved / 1 findingsRestores server audit logging by re-emitting audit entries through the AUDIT marker, ensuring entries reach audit.log as intended. Consider if pinning the AuditLogRepository logger to INFO permanently suppresses necessary DEBUG-level troubleshooting logs. 💡 Quality: Pinning AuditLogRepository logger to INFO suppresses its DEBUG logs📄 conf/openmetadata.yaml:182-185 📄 openmetadata-service/src/main/java/org/openmetadata/service/audit/AuditLogRepository.java:74-78 📄 openmetadata-service/src/main/java/org/openmetadata/service/audit/AuditLogRepository.java:107-117 The new 🤖 Prompt for agentsOptionsDisplay: compact → Showing less information. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
|
The Python checkstyle failed. Please run You can install the pre-commit hooks with |
Backport of #28771 to the
1.12.11release branch.Original fix (#28770 / #28771)
Audit-to-file logging silently broke in #23733: gutting
AuditEventHandlerremoved the only emitter of theAUDITlog marker, so theaudit.logappender created the file but never wrote to it.This re-emits each audit entry through the
AUDIT-marked logger fromAuditLogRepository.write(), gated on a successful (non-duplicate) DB insert so the publisher+consumer dual-write path does not double-log. Emits a compact one-line summary at INFO. Hardensconf/openmetadata.yaml: pins the audit logger to INFO so capture is independent ofLOG_LEVEL, and excludes audit lines from the console appender so they land only inaudit.log.Cherry-pick adjustments for 1.12.11
1.12.11does not have theEventType.ENTITY_LINEAGE_ADDED/UPDATED/DELETEDvalues (that feature is only onmain), sowritePersistsLineageChangeEvents(and its now-unused imports) was removed. NoENTITY_LINEAGEenum values were added. The two audit-marker tests (writeEmitsAuditMarkerWhenRowInserted,writeSkipsAuditMarkerWhenRowDeduplicated) are retained and useENTITY_CREATED, which is in1.12.11'sSUPPORTED_EVENT_TYPES.conf/openmetadata.yaml—1.12.11's console appender useslogFormat:(not thelayout:block onmain), so its structure was preserved and only the intendedfilterFactories: audit-exclude-filter-factorywas added. The audit-loggerlevel: INFOpin applied unchanged.The three production files (
AuditLogRepository,AuditLogger,CollectionDAO) match the original commit exactly.Verification
mvn -pl openmetadata-service test-compile→ BUILD SUCCESSmvn -pl openmetadata-service spotless:check→ BUILD SUCCESSAuditLogRepositoryTest→ Tests run: 2, Failures: 0, Errors: 0🤖 Generated with Claude Code