Search code examples
consulconsul-kv

Consul KV store endpoints


I am working on designing a little project where I need to use Consul to manage application configuration in a dynamic way so that all my app machines can get the configuration at the same time without any inconsistency issue. We are using Consul already for service discovery purpose so I was reading more about it and it looks like they have a Key/Value store which I can use to manage my configurations.

We already have a Consul up and running and below is the url I get if I click Key/Value store tab:

http://consul.host.orcld.com/ui/#/dc1/kv/

I am trying to do below things with the Consul through command line as of now:

  1. Create new key/value in Consul.
  2. Update value of existing key.
  3. Keep a watch on the existing key so that if value changes then I get notified and it can show me the new value of that key.

Now I already have few keys created with some values in it through ui so I was thinking to get value of that key. Below is the image but I am confuse on how can I get the value of this key in the command line:

enter image description here

I tried with below curl call but it doesn't give me the value of it as I get 404 Not Found? Am I doing anything wrong here?

curl -XGET http://consul.host.orcld.com/vi/kv/example/reaper

Also how can I create new key/value and keep a watch on existing key through command line as well?


Solution

  • Try this below format, replace v1 instead of vi

    curl http://127.0.0.1:8500/v1/kv/example/reaper
    

    Documentation : https://www.consul.io/api/kv.html