Skip to main content

Introspection

Restate exposes information on invocations and application state via its CLI and Introspection SQL API. You can use this to gain insight into the status of invocations and the service state that is stored.

This can be useful for troubleshooting. For example, a Virtual Object might be blocked and you want to kill the invocation that is blocking it, but you don't know the invocation ID. Or you want to check what is currently stored in the state of a service.

The CLI is the easiest way to get started with introspection.
Have a look at the installation guide for the CLI.

Inspecting invocations

Listing ongoing invocations


restate invocations list

Retrieving the status of an invocation


restate invocations describe <INVOCATION_ID>

The status is either:

  • pending: enqueued waiting for its turn
  • ready: ready to be processed, but not yet running
  • running: actively processing
  • backing-off: retrying due to a failure
  • suspended: waiting on some external input (e.g. request-response call, awakeable, sleep, ...)
  • completed: completed (this is shown only for idempotent invocations)

Inspecting the invocation journal


restate invocations describe <INVOCATION_ID>

You see the journal printed in the output.

Inspecting invocation retries

To have a look at the invocations that are currently in a retry loop, you can execute:


restate invocations list --status backing-off

Listing invocations that are blocking a Virtual Object

You can retrieve the invocation ID that is currently blocking a Virtual Object via:


restate invocations list --service <SERVICE> --key <KEY>

Or list all invocations that are blocking any Virtual Object:


restate invocations list --virtual-objects-only

You can then use the invocation ID to kill the invocation.

Checking the last time an invocation was modified


restate invocations describe <INVOCATION_ID>

Check the Modified at field in the invocation information in the output.

Checking how an invocation was triggered

To find out if an invocation was triggered via the ingress or by another service:


restate invocations describe <INVOCATION_ID>

You can check this at the root of the tree in the invocation progress.

Retrieving the trace ID of an invocation


restate invocations describe <INVOCATION_ID>

Afterwards, you can use this trace ID to search for spans in Jaeger.

Listing inactive invocations

To list the oldest invocations that are not making progress:


restate invocations list --oldest-first --status pending,backing-off,suspended

Listing zombie invocations

Zombie invocations are invocations that are pinned to a specific deployment but that deployment was forcefully removed. You can list them by executing:


restate invocations list --zombie

Inspecting application state

To retrieve the state of a specific service and service key, do:


restate kv get <SERVICE_NAME> <SERVICE_KEY>

Output

🤖 State:
―――――――――
service counter
key bob
KEY VAL
seen 8

info

If the values are not JSON-encoded UTF-8 strings, then it is also possible to use the --binary flag, and get the value as base64 encoded string.

To edit application state

To edit the application state, do:


restate kv edit <SERVICE_NAME> <SERVICE_KEY>

This command opens your default editor (as configured in the cli env). It sends the new state values back to the runtime to be applied.

State as binary

Use --binary if the values are not JSON-encoded UTF-8 strings. In this case, you need to decode the base64-encoded string, and encode it back to base64 after editing.

State as JSON objects

Use --plain to retrieve the state as a JSON object. This can be useful in combination with tools like jq for example:


restate kv get counter bob --plain | jq '.seen'

Editing state during ongoing invocations

If during the editing of the state with the CLI, an invocation changed the state as well, then the edit of the CLI will not take affect. If you want the CLI state edit to be applied even if the state has changed in the meantime, then use the --force flag.

An example on how to edit the K/V state of the service counter for the key bob:


restate kv edit counter bob

Output

ℹ️ About to write the following state :
―――――――――――――――――――――――――――――――――――――――
service counter
key bob
force? false
binary? false
KEY VAL
seen 8
✔ Are you sure? · yes
Enqueued successfully for processing