This topic introduces the different output formats for the Vault Command Line Interface (Vault CLI). Vault CLI supports the following output formats:
The table
format is the default output for Vault CLI commands, but sometimes we need more information from the command output, like the request_id
, lease_id
or some other metadata
. We can get these information by converting our command output to JSON
or YAML
format.
You can specify the Vault CLI output to a particular format using the following:
-
Using the
VAULT_FORMAT
environment variable – This command sets the output format tojson
for the CLI commands in this command line session until the variable is changed, unset or the session ends.$ export VAULT_FORMAT="json"
-
Using the
-format
option on the command line – The following example sets the output of only this one command tojson
. Using this option on the command overrides any currently set environment variable. Make sure to insert the-format
field after the command$ vault kv get -format=json kv/test
Examples:
Default regular CLI output example (table
format):
[vault ~]# vault kv get kv/test
======= Metadata =======
Key Value
--- -----
created_time 2022-04-27T21:14:02.215412783Z
custom_metadata <nil>
deletion_time n/a
destroyed false
version 1
=== Data ===
Key Value
--- -----
foo bar
CLI output example (json
format):
[vault ~]# vault kv get -format=json kv/test
{
"request_id": "d415555d-7785-582d-0727-0fc650eb3ec1",
"lease_id": "",
"lease_duration": 0,
"renewable": false,
"data": {
"data": {
"foo": "bar"
},
"metadata": {
"created_time": "2022-04-27T21:14:02.215412783Z",
"custom_metadata": null,
"deletion_time": "",
"destroyed": false,
"version": 1
}
},
"warnings": null
}
CLI output example (yaml
format):
[vault ~]# vault kv get -format=yaml kv/test
data:
data:
foo: bar
metadata:
created_time: "2022-04-27T21:14:02.215412783Z"
custom_metadata: null
deletion_time: ""
destroyed: false
version: 1
lease_duration: 0
lease_id: ""
renewable: false
request_id: 693ef57f-b995-f294-ff54-ae9945a740a4
warnings: null
For more information, please refer to our official documentation listed below:
https://www.vaultproject.io/docs/commands#vault_format
https://www.vaultproject.io/docs/commands/read#format
https://www.vaultproject.io/docs/commands/write#format