Audit Logging
Pilot records mutating operations to a Kafka topic for compliance and traceability. When authentication is enabled, audit events capture who performed what action and when.
How It Works
- Mutating API requests (POST, PUT, DELETE), MCP and assistant tool calls, and changes Pilot makes on its own generate audit events
- Events are produced to the
__pilot_audit_logKafka topic - Events include: action type, user identity, timestamp, request details, and result
- Reassignments are recorded when they are submitted, not when they finish. If the operation fails afterwards, Pilot records the action again with status
500and the reason inerror. A cancel is recorded as its own event. - The audit topic is created automatically on startup with
cleanup.policy=delete
Event Sources
The method field identifies where an event came from:
method | Source | userId |
|---|---|---|
POST, PUT, DELETE | REST API request | Authenticated user (AUDIT_USER_ID_CLAIM), empty without authentication |
MCP | MCP client tool call | Authenticated caller, or token owner for PAT mutations; requestedBy is omitted when it matches userId |
CHAT | Assistant tool call | Conversation owner who approved the action; requestedBy holds chat-llm:<owner> |
INTERNAL | Change Pilot made on its own | pilot |
provider is the auth provider of the user, pat for MCP sessions authenticated with a personal access token, and empty on INTERNAL events.
Large Change Lists
Events that list partition changes, such as reassignments.apply, selfheal.apply and broker.maintenance.set, carry one row per partition in after. A leader election (ple.trigger) is recorded with status 207 when some elections failed and 500 when all failed, with the failed partitions in error.
Lists longer than 500 rows are written as several records that share a chunkGroup. The API and the Audit Log page merge them into one event. If some records are not available, the merged event sets chunksMissing to their number and after holds only part of the rows. If you read the topic directly, merge the records by chunkGroup.
Broker Maintenance
A maintenance drain is recorded as broker.maintenance.set when its moves are submitted, with one row per partition in after and these fields:
| Field | Content |
|---|---|
brokerId | Drained broker; for a drain of several brokers, the first in ascending order |
query.brokerIds | Every drained broker, ascending and comma separated, for example 1,4 |
query.targetBrokers | Requested target brokers, when the drain names any |
query.bulkId | The drain’s monitored operation, when it moves partitions |
- A forced drain first records
broker.maintenance.set.overridewith the same broker fields and the overridden checks inerror:rf_reduction_<n>_partitions,skipped_<n>_partitionsorrack_collapse_<n>_partitions. - A drain that fails records
broker.maintenance.setagain with status500and the cause inerror. - When the drain’s moves end and partitions still have a replica on a drained broker, Pilot records
broker.maintenance.residualwith status500, the number of partitions inerrorand one row per partition inafter. See After the Drain.
Demo License Start
Pilot records a demo license start as license.update with the user who started it. after carries termsAccepted and termsUrl, the address of the Calinora Terms the user accepted.
Changes Pilot Makes on Its Own
Pilot records changes it makes without a request under userId pilot and method INTERNAL, with an empty provider and no requestId. The Audit Log page shows them under Pilot.
| Action | Path | Recorded when |
|---|---|---|
selfheal.apply | /self-healing/<trigger> | An automatic apply submits reassignments (status 202) or fails after submission (status 500) |
selfheal.cancel | /self-healing/<type>/cancel | The execution window closes on a running self-heal and Pilot cancels its active reassignments |
license.update | /license/auto-fetch | The license auto-fetch changes the license state, ID, plan or expiry, or loads a token that is rejected |
broker.expire | /health-monitor/broker-expiry | The health monitor stops tracking a broker that stayed unavailable and hosted no replica for PILOT_BROKER_EXPIRY |
agent.renew-cert | /agents/renew-cert | Pilot signs a renewed client certificate for a Pilot Agent |
rolling-restart.* | /rolling-restart | Each step of a rolling restart; query.restartId identifies the restart. rolling-restart.dismiss is not one of them: it records a user’s request that dismisses the outcome of a failed or cancelled restart |
throttles.reconcile | /throttles/reconcile | After a standalone start, Pilot removes replication throttles an earlier run of Pilot set. See Reassignments Found at Startup |
throttles.ownership | /throttles/ownership | Standalone, Pilot finds a broker replication throttle it did not set, or one someone changed after Pilot set it, and leaves it as it is. See Throttles Pilot Did Not Set |
throttles.ha-ownership | /throttles/ha-ownership | In HA mode, Pilot leaves a replication throttle to an operator, records it as a leftover, or finds that one of its throttle requests did not end as sent. See HA replication throttles |
reassignments.timeout-revert | /reassignment-monitor/timeout | A reassignment that no operation drives any more, for example after a cancel, is still running 12 hours after it was last submitted to Kafka. Pilot cancels it back to its old replicas |
Automatic Applies
A selfheal.apply event is written when a self-healing loop submits its plan for execution, before any move is sent to Kafka. Follow reassignment progress for the outcome.
| Field | Content |
|---|---|
status | 202 |
proposalId | Proposal the plan came from |
topic | Empty, since a plan spans topics |
query.trigger | activity, critical or rf |
query.healingType | Self-healing type whose window, cooldown and cap applied: the trigger |
query.moves | Number of partitions submitted |
query.bulkId | Monitored bulk operation |
after | Per partition: topic, partitionId, oldReplicas and oldLeader read from live metadata at submission, newReplicas and newLeader as submitted |
An apply that fails after submission, or whose execution window closes while it runs, writes one more event with status 500, error and query.moves set to the planned count. An apply refused before submission writes no event. The refusal is logged and counted as pilot_selfhealing_runs_total{result="error"}.
A dry run (PILOT_HEAL_DRY_RUN=true) and a cycle skipped by a gate, such as the time window, cooldown or license, write nothing. Use the self-healing metrics for skips.
selfheal.apply, throttles.reconcile, throttles.ownership, throttles.ha-ownership and reassignments.timeout-revert events cannot be reverted from the Audit Log or with the MCP revert_audit_event tool.
HA Throttle Events
throttles.ha-ownership events name the throttle in query.resource (broker:<id> or topic:<name>) and query.key, and carry a query.reason:
query.reason | Meaning |
|---|---|
operator-changed | An operator changed a value Pilot set. Pilot leaves that key to the operator for the rest of the operation |
superseded | A request Pilot could not confirm was replaced by a third value. Pilot leaves the key to the operator |
not-applied | A request Pilot could not confirm did not take effect |
operator-value-lost | A late request of Pilot’s replaced or removed a value a third party set while the request was open |
late-removal | One of Pilot’s values reappeared after removal and is removed again |
skipped | Pilot released entries without a request because the topic was deleted or recreated |
residual | Pilot recorded a leftover; query.value names the reason: unreachable, stuckForeignMove, refused or unobservable |
residual-dropped | The leftover record was full, so Pilot dropped this entry; query.value holds the values or entries to remove by hand |
Topic Configuration
The audit topic’s name, retention, partition count, and replication factor are all configurable via environment variables:
| Variable | Default | Description |
|---|---|---|
AUDIT_ENABLED | true | Enable audit event logging. HA refuses to start with false, 0 or no |
AUDIT_TOPIC | __pilot_audit_log | Kafka topic name |
AUDIT_RETENTION_MS | 2592000000 (30 days) | Topic retention in milliseconds |
AUDIT_PARTITIONS | 1 | Number of partitions |
AUDIT_REPLICATION_FACTOR | 0 (cluster default) | Replication factor for a new topic (0 uses the cluster’s default, see below) |
AUDIT_USER_ID_CLAIM | upn | Identity recorded as userId: upn (default), sub or email. Other values fall back to upn, then sub, then email |
AUDIT_STORE_MAX_ITEMS | 10000 | Max audit events kept in memory for the UI |
Pilot creates the topic on startup if it does not exist. Standalone, it sets cleanup.policy=delete and retention.ms from AUDIT_RETENTION_MS on every startup, also on an existing topic, and leaves the topic’s other settings, such as min.insync.replicas, as they are. Give AUDIT_TOPIC a topic of its own: standalone Pilot sets the cleanup policy and retention of any topic it names.
With AUDIT_REPLICATION_FACTOR=0, a new audit topic gets the brokers’ default.replication.factor, but never more replicas than brokers are up. To read that value Pilot needs DescribeConfigs on the cluster. Without it, Pilot logs a warning and the controller’s default applies. Pilot also logs a warning at startup when a topic has a single replica. It never changes the replication factor of an existing topic. The broker state and token topics follow the same rule.
In HA mode the audit topic needs one partition, at least 3 replicas and a min.insync.replicas of at least 2. Leave AUDIT_PARTITIONS at 1, and set AUDIT_REPLICATION_FACTOR to 3 or more or leave it unset. See High Availability.
Delivery
Pilot waits up to 5 seconds for Kafka to confirm each event. An unconfirmed event does not stop the change.
Standalone, Pilot retries an unconfirmed event in the background for up to 10 minutes. An event it cannot deliver is dropped, logged as an error and counted in pilot_audit_events_failure_total{error_type="dropped"}.
In HA mode, the events of an accepted operation are kept until the audit topic takes them, also across a restart or failover. While the topic refuses them, the active replica logs was not written and stays pending: check that the audit topic exists, is writable and has enough in-sync replicas.
After a failover an event can be written twice with the same eventId. Pilot’s audit view shows it once. If you read the topic directly, deduplicate by eventId.
An event of an accepted HA operation that is too large to write also stays pending, and the events after it are delivered. The active replica logs is too large to write with the reason, and each refused delivery counts in pilot_audit_events_failure_total{error_type="too_large"}.
If the reason says the audit topic refused the event as larger than its max.message.bytes, raise that setting to at least 1000000 bytes. For the default AUDIT_TOPIC:
kafka-configs.sh --bootstrap-server <broker> --alter --entity-type topics --entity-name __pilot_audit_log --add-config max.message.bytes=1048576Pilot delivers the event on its next try, within a minute. If the warning gives another reason or stays, report it to [email protected] with the warning.
Querying Audit Events
Via the UI
The Audit Log page in the Pilot dashboard provides a filterable view of all recorded events.
The page and the API list events by their ts, newest first, also an event that was delivered late.
Via the API
GET /api/v1/audit-logSupports query parameters for filtering:
| Parameter | Description |
|---|---|
action | Filter by action type |
userId | Filter by user ID (case-insensitive substring) |
after | Inclusive start timestamp (RFC3339) |
before | Inclusive end timestamp (RFC3339) |
search | Free-text search |
limit | Maximum events to return (default: 500) |
offset | Pagination offset |
Example:
curl "http://localhost:8080/api/v1/audit-log?action=reassignments.apply&after=2026-01-01T00:00:00Z"Reverting Actions
Some audit events support reversal:
POST /api/v1/audit-log/revertReversal submits another mutation, requires a valid license, and creates its own audit record. It does not erase the original event or undo application side effects. The UI checks current resource values before presenting supported reversals.
In High Availability mode a reversal needs an Idempotency-Key header.
Reassignment Review
Partition reassignment reversal has a separate preview at POST /api/v1/audit-log/revert/preview. Pilot resolves the stored audit event and compares its recorded original and target assignments with current Kafka placement. The review shows changes, partitions already at their original placement and blocked partitions. An event an MCP or assistant tool call recorded has no request path; the review and the reversal select it by its time and proposal, with the same checks, and refuse a selection that matches more than one recorded operation.
Applying requires the stored event selector and reviewFingerprint from the preview. Client-supplied replica arrays do not define reversal targets. Pilot rebuilds the review before submission and rejects changed evidence. Reversal can be blocked by placement drift, unavailable evidence, replica or minimum-ISR constraints, maintenance state, or unfinished reassignment and restart operations.
A nonempty accepted reversal returns HTTP 202 with an executionId. Follow reassignment progress for outcomes rather than treating acceptance as completion. If every partition is already at its original assignment, the response is a no-op. See the OpenAPI specification for request and response schemas.
Offset Reset Limits
Automatic consumer-group offset reversal is not available in the Audit Log UI. A successful reset event records the previous offsets, requested targets and Kafka request outcome. The offset-reset dialog separately rereads committed offsets, but those observations are not persisted as verified completion in the audit event. This limitation does not mean that the reset failed.
Kafka supports resetting offsets backwards. To restore a previous position, stop the group and review a new exact-offset reset against current offsets and retained log bounds. Records below the retained log start are gone; restoring an offset number cannot recover them or undo processing already performed.
The legacy direct reversal API still accepts previous offsets supplied by the caller. It does not provide the stored-event, drift and retention review described above for reassignments, and should not be treated as a verified undo operation.
Prometheus Metrics
| Metric | Description |
|---|---|
pilot_audit_events_total | Total audit events attempted |
pilot_audit_events_success_total | Events successfully delivered |
pilot_audit_events_failure_total | Failed deliveries (by error_type) |
pilot_audit_delivery_duration_seconds | Delivery latency |
pilot_audit_events_failure_total counts by error_type:
delivery_error,timeout,context_cancelled: a first delivery attempt that failed and is retriedtoo_large: a delivery attempt in HA mode of an event too large to writedropped: an event lost for good
A too_large event of an accepted HA operation stays pending; any other is dropped at once. Alert on lost events:
increase(pilot_audit_events_failure_total{error_type="dropped"}[15m]) > 0Alert on events too large to write:
increase(pilot_audit_events_failure_total{error_type="too_large"}[15m]) > 0Monitor the rate of first attempts that need a retry:
sum(rate(pilot_audit_events_failure_total{error_type!~"dropped|too_large"}[5m]))
/ sum(rate(pilot_audit_events_total[5m]))See Prometheus Metrics for the full metric reference.