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. You can inspect what is stored in Restate via the UI, via the CLI (via commands or SQL queries), and via curl.
You can use the UI to debug your applications. Have a look at the UI announcement blog post to get some inspiration on how you can use the UI for debugging and understanding your applications.

SQL over the data in Restate

Restate exposes the following SQL tables:
  • sys_invocation: to inspect invocations
  • sys_inbox: to inspect queue of pending invocations
  • sys_keyed_service_status: to inspect the status of a Virtual Object
  • sys_journal: to inspect the invocations’ journal
  • sys_service: to inspect the registered services
  • sys_deployment: to inspect service deployments
  • sys_idempotency: to inspect idempotency keys
  • state: to inspect application state
You can find the schema of each of the tables in the references. The Restate Introspection SQL API has been implemented based on DataFusion and supports standard SQL syntax.

Inspecting invocations

You can execute SQL queries via the CLI or over HTTP.

Inspecting application state

With the CLI

To retrieve the state of a specific service and service key, do:
restate kv get <SERVICE_NAME> <SERVICE_KEY>
Example output:
🤖 State:
―――――――――

service  counter
key      bob

KEY   VAL
seen  8
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.

With SQL queries

You can query the application state via the state table.
restate sql --json "select * from state where service_name = 'test.MyServiceName' and service_key = 'myKey';"
If your state value is a regular string, then you can access its content in the column value_utf8. To retrieve the state of a specific service name, service key and state key, do:
restate sql --json "select * from state where service_name = 'MyServiceName' and service_key = 'myKey' and key = 'myStateKey';"
The state key is the name you used to store the state with the SDK. For example, the code snippet ctx.set("count", 1) stores 1 under the key count.

Edit application state

You can edit the application state either via the state tab of the UI or via the CLI:
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. 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. 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'
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: