Skip to Content
ConfigurationAudit Logging

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_log Kafka 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 500 and the reason in error. 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:

methodSourceuserId
POST, PUT, DELETEREST API requestAuthenticated user (AUDIT_USER_ID_CLAIM), empty without authentication
MCPMCP client tool callAuthenticated caller, or token owner for PAT mutations; requestedBy is omitted when it matches userId
CHATAssistant tool callConversation owner who approved the action; requestedBy holds chat-llm:<owner>
INTERNALChange Pilot made on its ownpilot

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:

FieldContent
brokerIdDrained broker; for a drain of several brokers, the first in ascending order
query.brokerIdsEvery drained broker, ascending and comma separated, for example 1,4
query.targetBrokersRequested target brokers, when the drain names any
query.bulkIdThe drain’s monitored operation, when it moves partitions
  • A forced drain first records broker.maintenance.set.override with the same broker fields and the overridden checks in error: rf_reduction_<n>_partitions, skipped_<n>_partitions or rack_collapse_<n>_partitions.
  • A drain that fails records broker.maintenance.set again with status 500 and the cause in error.
  • When the drain’s moves end and partitions still have a replica on a drained broker, Pilot records broker.maintenance.residual with status 500, the number of partitions in error and one row per partition in after. 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.

ActionPathRecorded when
selfheal.apply/self-healing/<trigger>An automatic apply submits reassignments (status 202) or fails after submission (status 500)
selfheal.cancel/self-healing/<type>/cancelThe execution window closes on a running self-heal and Pilot cancels its active reassignments
license.update/license/auto-fetchThe license auto-fetch changes the license state, ID, plan or expiry, or loads a token that is rejected
broker.expire/health-monitor/broker-expiryThe health monitor stops tracking a broker that stayed unavailable and hosted no replica for PILOT_BROKER_EXPIRY
agent.renew-cert/agents/renew-certPilot signs a renewed client certificate for a Pilot Agent
rolling-restart.*/rolling-restartEach 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/reconcileAfter a standalone start, Pilot removes replication throttles an earlier run of Pilot set. See Reassignments Found at Startup
throttles.ownership/throttles/ownershipStandalone, 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-ownershipIn 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/timeoutA 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.

FieldContent
status202
proposalIdProposal the plan came from
topicEmpty, since a plan spans topics
query.triggeractivity, critical or rf
query.healingTypeSelf-healing type whose window, cooldown and cap applied: the trigger
query.movesNumber of partitions submitted
query.bulkIdMonitored bulk operation
afterPer 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.reasonMeaning
operator-changedAn operator changed a value Pilot set. Pilot leaves that key to the operator for the rest of the operation
supersededA request Pilot could not confirm was replaced by a third value. Pilot leaves the key to the operator
not-appliedA request Pilot could not confirm did not take effect
operator-value-lostA late request of Pilot’s replaced or removed a value a third party set while the request was open
late-removalOne of Pilot’s values reappeared after removal and is removed again
skippedPilot released entries without a request because the topic was deleted or recreated
residualPilot recorded a leftover; query.value names the reason: unreachable, stuckForeignMove, refused or unobservable
residual-droppedThe 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:

VariableDefaultDescription
AUDIT_ENABLEDtrueEnable audit event logging. HA refuses to start with false, 0 or no
AUDIT_TOPIC__pilot_audit_logKafka topic name
AUDIT_RETENTION_MS2592000000 (30 days)Topic retention in milliseconds
AUDIT_PARTITIONS1Number of partitions
AUDIT_REPLICATION_FACTOR0 (cluster default)Replication factor for a new topic (0 uses the cluster’s default, see below)
AUDIT_USER_ID_CLAIMupnIdentity recorded as userId: upn (default), sub or email. Other values fall back to upn, then sub, then email
AUDIT_STORE_MAX_ITEMS10000Max 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=1048576

Pilot 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-log

Supports query parameters for filtering:

ParameterDescription
actionFilter by action type
userIdFilter by user ID (case-insensitive substring)
afterInclusive start timestamp (RFC3339)
beforeInclusive end timestamp (RFC3339)
searchFree-text search
limitMaximum events to return (default: 500)
offsetPagination 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/revert

Reversal 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

MetricDescription
pilot_audit_events_totalTotal audit events attempted
pilot_audit_events_success_totalEvents successfully delivered
pilot_audit_events_failure_totalFailed deliveries (by error_type)
pilot_audit_delivery_duration_secondsDelivery latency

pilot_audit_events_failure_total counts by error_type:

  • delivery_error, timeout, context_cancelled: a first delivery attempt that failed and is retried
  • too_large: a delivery attempt in HA mode of an event too large to write
  • dropped: 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]) > 0

Alert on events too large to write:

increase(pilot_audit_events_failure_total{error_type="too_large"}[15m]) > 0

Monitor 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.

Last updated on