[ 
https://issues.apache.org/jira/browse/KNOX-3580?focusedWorklogId=1055322&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1055322
 ]

ASF GitHub Bot logged work on KNOX-3580:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 17/Nov/26 14:27
            Start Date: 17/Nov/26 14:27
    Worklog Time Spent: 10m 
      Work Description: 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.




Issue Time Tracking
-------------------

            Worklog Id:     (was: 1055322)
    Remaining Estimate: 0h
            Time Spent: 10m

>  Add log4j2 appender to POST audit events as JSON to an HTTP endpoint
> ---------------------------------------------------------------------
>
>                 Key: KNOX-3580
>                 URL: https://issues.apache.org/jira/browse/KNOX-3580
>             Project: Apache Knox
>          Issue Type: Task
>          Components: Server
>    Affects Versions: 3.0.0
>            Reporter: Tamás Hanicz
>            Assignee: Tamás Hanicz
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Add an AuditGateway log4j2 appender that sends each Knox audit record as a 
> JSON event to an HTTP endpoint. It is enabled only when the AUDIT_GATEWAY env 
> var is set; otherwise it does nothing.
> - Maps Knox action and outcome to a category/verb/outcome event, including 
> actor (act), target resource and correlation id.
> - Sends asynchronously from a bounded queue, with retries and a circuit 
> breaker.
> - Drains queued events on shutdown.
> - gateway-audit.log is unchanged.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to