github.com/outbrain/consul@v1.4.5/website/source/docs/commands/kv.html.md (about)

     1  ---
     2  layout: "docs"
     3  page_title: "Commands: KV"
     4  sidebar_current: "docs-commands-kv"
     5  ---
     6  
     7  # Consul KV
     8  
     9  Command: `consul kv`
    10  
    11  The `kv` command is used to interact with Consul's KV store via the
    12  command line. It exposes top-level commands for inserting, updating, reading,
    13  and deleting from the store. This command is available in Consul 0.7.1 and
    14  later.
    15  
    16  The KV store is also accessible via the
    17  [HTTP API](/api/kv.html).
    18  
    19  ## Usage
    20  
    21  Usage: `consul kv <subcommand>`
    22  
    23  For the exact documentation for your Consul version, run `consul kv -h` to view
    24  the complete list of subcommands.
    25  
    26  ```text
    27  Usage: consul kv <subcommand> [options] [args]
    28  
    29    # ...
    30  
    31  Subcommands:
    32  
    33      delete    Removes data from the KV store
    34      export    Exports part of the KV tree in JSON format
    35      get       Retrieves or lists data from the KV store
    36      import    Imports part of the KV tree in JSON format
    37      put       Sets or updates data in the KV store
    38  ```
    39  
    40  For more information, examples, and usage about a subcommand, click on the name
    41  of the subcommand in the sidebar or one of the links below:
    42  
    43  - [delete](/docs/commands/kv/delete.html)
    44  - [export](/docs/commands/kv/export.html)
    45  - [get](/docs/commands/kv/get.html)
    46  - [import](/docs/commands/kv/import.html)
    47  - [put](/docs/commands/kv/put.html)
    48  
    49  ## Basic Examples
    50  
    51  To create or update the key named "redis/config/connections" to the value "5" in
    52  Consul's KV store:
    53  
    54  ```text
    55  $ consul kv put redis/config/connections 5
    56  Success! Data written to: redis/config/connections
    57  ```
    58  
    59  To read a value back from Consul:
    60  
    61  ```text
    62  $ consul kv get redis/config/connections
    63  5
    64  ```
    65  
    66  Or you can query for detailed information:
    67  
    68  ```text
    69  $ consul kv get -detailed redis/config/connections
    70  CreateIndex      336
    71  Flags            0
    72  Key              redis/config/connections
    73  LockIndex        0
    74  ModifyIndex      336
    75  Session          -
    76  Value            5
    77  ```
    78  
    79  Finally, deleting a key is just as easy:
    80  
    81  ```text
    82  $ consul kv delete redis/config/connections
    83  Success! Data deleted at key: redis/config/connections
    84  ```
    85  
    86  For more examples, ask for subcommand help or view the subcommand documentation
    87  by clicking on one of the links in the sidebar.