Skip to content

AuditEvent

An AuditEvent records one action on one entity: who did it, under what authority, to what, from where, and when, and whether it was allowed. ConfigHub records one for each write through the API, refused and failed writes included, for each login and token exchange, for the writes it makes itself on someone's behalf, and for the commands an operator runs on the server. Together they are the Organization's audit log, the counterpart for ConfigHub's own entities of the Kubernetes audit log or a cloud provider's activity log.

AuditEvents belong to the Organization, not to a Space. Each is written in the transaction of the write it describes, so it is committed exactly when the change is, and a write that rolls back leaves none. Once written, an AuditEvent is never changed, and the API only lists and reads them: there is no create, update or delete. They are removed only by retention, a month at a time.

There is one AuditEvent per entity per action, not per request. A bulk patch of fifty Units records fifty events, which share a RequestID.

For how to read them and the questions they answer, see Auditing who did what.

Fields

When and how

Field Meaning
AuditEventID Identifies the event. An AuditEvent has no Slug, and is addressed by ID.
OccurredAt When the action happened: when the transaction of its write started.
RequestID The API request that made the action, which also appears in the server's request log. Every event of a bulk request has the same one. Empty for actions outside the API.
Origin What made the action. See Origin.

Who, and under what authority

Field Meaning
UserID The authenticated identity that acted. A bot or a ServiceAccount is a User of its own.
OnBehalfOfUserID The person a bot, a Trigger, a Link resolve or a ChangeOrder stage advance acted for.
ServiceAccountID The service account that acted, when one did.
Role The Organization role of the User at the time, such as admin.
Grants The grants that allowed the action. See Grants.
SourceIP, UserAgent Where the request came from. Hidden from most readers: see Who can read them.

What

Field Meaning
Action The verb. See Actions.
SubjectEntityType, SubjectEntityID The entity acted on, such as a Unit and its ID. EntityType is always AuditEvent, the type of the event itself.
SubjectSlug The entity's Slug as it was at the time, since it may have been renamed or deleted since.
SpaceID The Space of the entity acted on, when it is in one.
Outcome Succeeded, Denied when authorization refused it, or Failed when it was allowed but did not complete. A denied or failed write records the Action it attempted.
Error The message the caller was given when the action was denied or failed.

The change

The event says what changed without copying what ConfigHub already keeps.

Field Meaning
RevisionID The Revision that holds the change, when one does: a Unit's own Revision for a change to its configuration, or the backing Unit's Revision for a change to an entity that has one. The Revision has the diff, so the event does not repeat it. It may name a Revision since deleted with its Unit.
ChangedFields The fields the action changed.
Before, After The entity's document, or the merge-patch fields, before and after the action, when no Revision holds the change: a permission change, a delete, or a change to an entity with no backing Unit. Read-only fields are left out, which keeps out the fields that hold secrets.
HeadRevisionNum, HeadRevisionHash For a deleted Unit, the number and hash of its head Revision when it was deleted. Its metadata is in Before; its configuration data is not copied.

The values of credentials, such as keys and tokens, are never recorded; an event of one names it by ID.

Actions

Action names what was done; SubjectEntityType names what it was done to.

Kind Actions
Any entity type Create, Update, Patch, Delete, Archive, Unarchive, Move, Detach, Hide, Permission
Specific entity types Tag, Upload, Promote, RequestReview, DismissReview, AdvanceStage, RefreshStage, AddMember, RemoveMember, AddBotUser, RemoveBotUser
Authentication Login, TokenExchange, RefreshToken, BrowserSession
Operators, on the server EnableUser, DisableUser, DeleteUser, EnableOrganization, DisableOrganization, DeleteOrganization, SetQuota, Grant, Revoke

A few are worth knowing:

  • Update covers the changes ConfigHub makes to a Unit for someone, by a Trigger or a resolve, as well as those a person makes directly. Origin tells them apart.
  • Permission is a change to an entity's Permissions, on any type.
  • Hide is a change to an entity's HiddenReasons; see hidden entities.
  • Update of a User records a change to the Groups a User is in, which ConfigHub sees at the User's next login.
  • Authentication events are about the User who logged in. A refused credential is a Login with Outcome Denied.
  • DisableUser also comes from the API: deleting a ServiceAccount disables the User it acts as, recorded beside the Delete with Origin API.

cub audit explain Action lists every Action.

Origin

Origin What made the action
API A request to the API, from cub, the UI, a bot or anything else.
Trigger A Unit change made only by Triggers, as part of resolving the Unit.
Resolve A Unit change made by resolving it: a Link, or a clone reset from its upstream, with or without Triggers.
ChangeOrder A ChangeOrder stage advanced by the server, such as when a write completed it.
System The server itself, with no caller: a CommandRun that expired or timed out, or the removal of a month of AuditEvents by retention.
AdminCLI, IdentityCLI An operator command run on the server, outside the API, which names the operator, OS user and host in UserAgent.
Migration A database migration.

The writes ConfigHub makes for someone name that person in OnBehalfOfUserID: the User whose write started the resolve, or the ChangeOrder's creator when a timer advanced its stage.

Grants

Grants lists what allowed the action, each with a Source:

Source The grant
Role The User's Organization role.
SpaceGrant An entry in the Permissions of the Space the entity is in.
EntityPermissions An entry in the Permissions of the entity itself.
Group An entry that named a Group, with the Group's GroupID.

EntityType and EntityID name the entity holding the grant. The event records the Group a grant named, which says the action was allowed through that Group. Whether the User was in the Group at the time is the identity provider's record, since membership of people in Groups is managed there.

Who can read them

An AuditEvent has no Permissions of its own. Who may read one follows from the entity it is about:

  • The admin and manager roles read every event of the Organization.
  • Anyone reads the events of their own actions.
  • Anyone who may view an entity reads the events about it. An event about an entity that has been deleted is read by whoever may view the contents of the Space it was in, while that Space exists.
  • Events of logins, tokens and credentials, about a User, UserKey, UserToken, OAuthClient or OrganizationMember, are read only by the User who made them and by the admin and manager roles.

SourceIP and UserAgent are empty in an event someone else made, unless the reader has the admin or manager role: being able to see an entity does not let you learn where other people work from. An event you may not read is reported as not found.

A User and a Group belong to no Organization, so the events of a login's change to them are recorded in the Organization the User logged in to.

Retention

AuditEvents are kept for the same period in every Organization, 400 days by default, so that an annual review covers its whole year. A self-hosted server sets it with CONFIGHUB_AUDIT_LOG_RETENTION, from 90 to 1000 days; there is no API to change it. Events are removed a whole calendar month at a time, so each is kept for between the retention period and a month longer, and never removed from the middle. Each removal is itself recorded, as an event with Origin System.

To keep events for longer, copy them elsewhere; see Sending audit events to another system.

What is not recorded

  • Reads. Listing and getting entities is not recorded, nor is a refused read. The server's request log records each request.
  • Changes to Group membership in the identity provider, which keeps its own record. ConfigHub records the change to a User's Groups when it sees it, at the User's next login.
  • The configuration data of a deleted Unit. Its Revisions are deleted with it, and the event keeps its head Revision's number and hash, not its data.

API and CLI

  • API: GET /audit_event lists them, with where, order_by and paging, and GET /audit_event/{audit_event_id} reads one. cub audit explain --where lists the attributes a where expression can name: Action, AuditEventID, Grants, OccurredAt, OnBehalfOfUserID, OrganizationID, Origin, Outcome, RequestID, Role, SpaceID, SubjectEntityID, SubjectEntityType and UserID.
  • CLI: cub audit, with list, get, tail, report and explain.