Skip to content

Events

The events commands let you query events from an event sequence and retrieve the highest used sequence number. Use these commands to verify that events were appended, inspect their content, and understand the current state of an event log.

Retrieves events from an event sequence, with optional filtering by range, event source, and event type.

Terminal window
cratis chronicle events get
FlagDescription
-e, --event-store <NAME>Event store to query. Defaults to default.
-n, --namespace <NAME>Namespace to query. Defaults to Default.
--sequence <NAME>Event sequence to query. Defaults to the event log.
--from <SEQUENCE_NUMBER>Start of the sequence range (inclusive, 0-based). Defaults to 0.
--to <SEQUENCE_NUMBER>End of the sequence range (inclusive). Omit to read to the current tail.
--event-source-id <ID>Filter events to a single event source.
--event-type <TYPES>Comma-separated list of event type names or name+generation pairs to filter by.

Use --output plain when processing events in scripts. The plain format is approximately 25 times smaller than JSON because it omits embedded metadata, context headers, and schema details. Use --output json when you need the full event document including metadata.

Get all events from the event log:

Terminal window
cratis chronicle events get

Get events from sequence number 100 to 200:

Terminal window
cratis chronicle events get --from 100 --to 200

Get all events for a specific event source:

Terminal window
cratis chronicle events get --event-source-id "user-42"

Filter to a single event type:

Terminal window
cratis chronicle events get --event-type UserRegistered

Filter to a specific generation of an event type:

Terminal window
cratis chronicle events get --event-type UserRegistered+2

Filter to multiple event types:

Terminal window
cratis chronicle events get --event-type UserRegistered,UserEmailChanged

Combine filters for targeted inspection:

Terminal window
cratis chronicle events get --event-source-id "user-42" --event-type UserRegistered --output json

Gets the highest used sequence number in an event sequence. This is the tail of the log — the sequence number of the last appended event. It is not a count of events: gaps may exist in the sequence if events were redacted or sequences were not used contiguously.

Terminal window
cratis chronicle events tail
FlagDescription
-e, --event-store <NAME>Event store to query. Defaults to default.
-n, --namespace <NAME>Namespace to query. Defaults to Default.
--sequence <NAME>Event sequence to query. Defaults to the event log.
--event-type <TYPE>Return the tail sequence number for a specific event type.
--event-source-id <ID>Return the tail sequence number for a specific event source.

With --output plain, the command returns a single number on one line, making it easy to capture in a script:

Terminal window
TAIL=$(cratis chronicle events tail --output plain)

Get the tail sequence number of the event log:

Terminal window
cratis chronicle events tail

Get the tail for a specific event source:

Terminal window
cratis chronicle events tail --event-source-id "user-42"

Get the tail for a specific event type:

Terminal window
cratis chronicle events tail --event-type UserRegistered

Capture the tail number in a script:

Terminal window
TAIL=$(cratis chronicle events tail -e myapp --output plain)
echo "Current tail: $TAIL"