Most CLI commands that return data support theDocumentation Index
Fetch the complete documentation index at: https://docs.nebius.com/llms.txt
Use this file to discover all available pages before exploring further.
--format jsonpath='<expression>' parameter. You can use it to extract values, such as a resource ID, name or IP address, without post-processing the full output.
For example, to return only the ID of a virtual machine (VM), add the following parameter to the nebius compute instance create command:
kubectl. This implementation extends the original JSONPath syntax with additional functions, such as list iteration, but it doesn’t support all JSONPath features.
Syntax
A JSONPath expression selects values from the JSON object returned by a CLI command. When you write JSONPath expressions for the--format jsonpath parameter, consider the following:
-
Enclose expressions in curly braces. However, if you omit them, the CLI still parses the value.
The
$operator is optional because expressions start from the root object by default. As a result, these expressions are equivalent: -
Use double quotes to quote literal text inside JSONPath expressions:
-
Use the
rangeandendoperators to iterate over lists: -
To step backward through a list, use negative slice indices. The negative indices don’t wrap around a list and are valid if
-index + listLength >= 0. For example: -
Complex values, such as objects or lists, are printed in their string representation. If you need stable machine-readable output for further processing, use
--format json.
Common expressions
| Expression | Description |
|---|---|
{@} | Returns the current object. |
{.metadata.name} | Returns the metadata.name value. |
{.items[0]} | Returns the first item from the items list. |
{.items[-1:]} | Returns the last item from the items list. |
{.items[*].metadata.name} | Returns the metadata.name value for all items in the items list. |
{.items[*]['metadata.name', 'status.state']} | Returns the metadata.name and status.state values for all items in the items list. |
{range .items[*]}...{end} | Iterates over the items list. |
Examples
Getting a value from a single resource
Below are several examples of how to get a value from a single resource:-
Get a name of a VM:
Example output:
-
Get a status of a VM:
Example output:
-
Get a bucket ID by the bucket name:
Example output:
-
Get a public IP address of a VM by the VM name:
Example output:
Getting values from a list
Below are several examples of how to get values from a list:-
Get the name of the first VM from the list:
Example output:
-
Get names and statuses of all VMs:
Example output:
Formatting list output
Print each VM name and status on a separate line:Limitations
JSONPath regular expressions aren’t supported. In this context, a regular expression is a pattern used in a JSONPath filter to match field values. For example, the following expression tries to find VMs whose names start withvm:
=~ regular expression match operator. The command fails while parsing the JSONPath expression, before matching it against command output.
Match values with regular expressions by using jq:
jq to be installed.
Example output: