hanicz opened a new pull request, #1518: URL: https://github.com/apache/knox/pull/1518
[KNOX-3580](https://issues.apache.org/jira/browse/KNOX-3580) - Add log4j2 appender that POSTs audit events as JSON ## What changes were proposed in this pull request? Adds an `AuditGateway` log4j2 appender that sends every Knox audit record as a JSON event to an HTTP endpoint, alongside `gateway-audit.log`. - `AuditGatewayAppender`: maps each event on the calling thread and puts it on a bounded queue; when the queue is full the event is dropped and counted. `workers` threads (1–4) POST each event once with Apache HttpClient. Failures are logged and not retried. On stop or JVM exit the queue is drained within `drainTimeoutMs`. - `AuditEventMapper`: maps the Knox audit context, correlation context and MDC to an event with `event_id`, `event_time`, `sub`/`act`, `action` (category/verb/name), `outcome`/`verdict`, `target_resource`, `correlation_id` and `context`. The client IP is not sent. - `UuidV7`: time-ordered event ids. - `gateway-log4j2.xml`: declares the appender and references it from the `audit` logger. Leaving the appender out of the config disables it entirely. Attributes: `endpoint`, `path`, `sourceSystem`, `podName`, `queueSize`, `workers`, `requestTimeoutMs`, `drainTimeoutMs`. ## How was this patch tested? ``` <AuditGateway name="auditgateway" endpoint="127.0.0.1:4319" path="/api/v1/audit/events" sourceSystem="system:serviceaccount:local:knox" /> ``` `<AppenderRef ref="auditgateway" />` - Unit tests for the mapper, the appender (against a local HTTP stub) and `UuidV7`. - Ran a local gateway against a stub endpoint (dispatch, KnoxIDF token, token exchange, delegation policy, health): every `gateway-audit.log` record was received as one valid event. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
