Event querying with Cratis CLI
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.
cratis chronicle events getOptions
Section titled “Options”| Flag | Description |
|---|---|
-e, --event-store <NAME> |
Event store to query. Defaults to the active context’s event store, then default. |
-n, --namespace <NAME> |
Namespace to query. Defaults to the active context’s namespace, then 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 event type identifiers. Filtering uses only identifiers; a +<generation> suffix is accepted but does not restrict generation. |
Output tip
Section titled “Output tip”Use --output plain when processing events in scripts.
Examples
Section titled “Examples”Get all events from the event log:
cratis chronicle events getGet events from sequence number 100 to 200:
cratis chronicle events get --from 100 --to 200Get all events for a specific event source:
cratis chronicle events get --event-source-id "user-42"Filter to a single event type:
cratis chronicle events get --event-type UserRegisteredAdding +2 still filters only by the UserRegistered identifier, not by generation:
cratis chronicle events get --event-type UserRegistered+2Filter to multiple event types:
cratis chronicle events get --event-type UserRegistered,UserEmailChangedCombine filters for targeted inspection:
cratis chronicle events get --event-source-id "user-42" --event-type UserRegistered --output jsonGets 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.
cratis chronicle events tailOptions
Section titled “Options”| Flag | Description |
|---|---|
-e, --event-store <NAME> |
Event store to query. Defaults to the active context’s event store, then default. |
-n, --namespace <NAME> |
Namespace to query. Defaults to the active context’s namespace, then 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. |
Output
Section titled “Output”With --output plain, the command prints a TailSequenceNumber header line followed by the number. Use -q (--quiet) to get only the number on one line, making it easy to capture in a script:
TAIL=$(cratis chronicle events tail -q)Examples
Section titled “Examples”Get the tail sequence number of the event log:
cratis chronicle events tailGet the tail for a specific event source:
cratis chronicle events tail --event-source-id "user-42"Get the tail for a specific event type:
cratis chronicle events tail --event-type UserRegisteredCapture the tail number in a script:
TAIL=$(cratis chronicle events tail -e myapp -q)echo "Current tail: $TAIL"