Skip to main content

Audit events

Ory Talos emits structured audit events via OpenTelemetry span events for all significant lifecycle operations. Events are attached to the active OTEL span and forwarded to any configured OTEL collector. They are never persisted locally.

Each event carries a set of structured attributes that provide context about the operation, the actor, and the affected resource.

Event types

ConstantEvent NameDescription
EventIssuedAPIKeyCreatedIssuedAPIKeyCreatedEventIssuedAPIKeyCreated is emitted when Talos issues a new API key.
EventImportedAPIKeyCreatedImportedAPIKeyCreatedEventImportedAPIKeyCreated is emitted when an externally created API key is imported into Talos.
EventIssuedAPIKeyUpdatedIssuedAPIKeyUpdatedEventIssuedAPIKeyUpdated is emitted when an issued API key's metadata is updated.
EventImportedAPIKeyUpdatedImportedAPIKeyUpdatedEventImportedAPIKeyUpdated is emitted when an imported API key's metadata is updated.
EventIssuedAPIKeyRevokedIssuedAPIKeyRevokedEventIssuedAPIKeyRevoked is emitted when an issued API key is revoked.
EventImportedAPIKeyRevokedImportedAPIKeyRevokedEventImportedAPIKeyRevoked is emitted when an imported API key is revoked.
EventIssuedAPIKeyRotatedIssuedAPIKeyRotatedEventIssuedAPIKeyRotated is emitted when an issued API key is rotated.
EventAPIKeyVerifiedAPIKeyVerifiedEventAPIKeyVerified is emitted when an API key is successfully verified.
EventAPIKeyVerificationFailedAPIKeyVerificationFailedEventAPIKeyVerificationFailed is emitted when an API key verification fails.
EventAPIKeyImportFailedAPIKeyImportFailedEventAPIKeyImportFailed is emitted when an API key import fails.
EventAPIKeyDerivedTokenAPIKeyDerivedTokenEventAPIKeyDerivedToken is emitted when a session token is derived from an API key.
EventImportedAPIKeyDeletedImportedAPIKeyDeletedEventImportedAPIKeyDeleted is emitted when an imported API key is permanently deleted.

Event attributes

Each event carries the following OTEL span event attributes:

OTEL KeyStruct FieldTypeRequiredDescription
ProjectIDNetworkIDuuid.UUIDRequiredNetwork (tenant) ID the event belongs to.
APIKeyIDKeyIDstringOptionalResource ID of the affected API key.
APIKeyPrefixPrefixstringOptionalPublic prefix of the affected API key.
KeyTypeKeyTypestringOptionalKey origin, either "issued" or "imported".
OperationOperationstringOptionalOperation name, for example "rotate".
ReasonReasonstringOptionalFailure reason or other context for the event.
ActorIDActorIDstringOptionalID of the actor who performed the operation.
ExpiryExpiry*time.TimeOptionalExpiry timestamp of the affected key, if set.
VisibilityVisibilitystringOptionalKey visibility, either "public" or "secret".
metadata.Metadatamap[string]stringOptionalEvent-specific key-value context, emitted under the metadata.* prefix.

Dynamic metadata attributes

The metadata.* prefix supports arbitrary key-value pairs for event-specific context. Metadata keys are prefixed with metadata. in OTEL attributes. For example, a metadata entry {"token_type": "jwt"} becomes the OTEL attribute metadata.token_type with value jwt.

Metadata is optional and varies by event type. The following keys are emitted by Talos today:

  • algorithm — Signing algorithm of a derived token (EventTokenDerived, e.g., RS256, HS256).
  • ttl — Requested token lifetime in seconds (EventTokenDerived).
  • old_key_id — ID of the previous key during rotation (EventAPIKeyRotated).
  • old_expires_at — Previous expiry, RFC-3339 (EventAPIKeyRotated, only if the previous key had one).
  • index — Zero-based row index of the failed entry (EventAPIKeyImportFailed).
  • error_code — Stable error code for the failure (EventAPIKeyImportFailed).
  • credential_type — Credential class that failed verification (EventAPIKeyVerificationFailed; e.g., issued, imported, derived_jwt, derived_macaroon).
  • initiated_by — Set to self when self-revoke produced the event (EventAPIKeyRevoked).

Operational notes

  • EventAPIKeyVerificationFailed emissions are rate-limited per network (NID) to at most failureEventRateLimit (10) events per failureEventWindow (1 minute). Excess failures are silently dropped with a DEBUG-level log line. Security alerting that relies on this event must account for throttling — see internal/verifier/verifier.go.
  • EventAPIKeyVerified is not emitted on successful verification. Verify is a hot path; only failures produce audit events.
  • EventAPIKeyRevoked carries the revocation Reason attribute (mapped from talosv2alpha1.RevocationReason) when the reason is not UNSPECIFIED. Self-revoke emissions additionally set the metadata.initiated_by="self" key.

Emitting events

Events are constructed using the fluent builder pattern:

emitter := events.NewOTELEmitter()
events.New(events.EventIssuedAPIKeyCreated).
WithNetworkID(networkID).
WithKeyID(keyID).
WithPrefix("talos").
WithActor(actorID).
Emit(ctx, emitter)

Events are attached to the active OpenTelemetry span. If no span is recording, the event is silently dropped.