1

I want to retrieve all saved keys and values of consul servers using its http api. Or at least how to get all saved keys using http api?

pupil
  • 318
  • 2
  • 16

3 Answers3

2

I used python-consul library. Here's the example

import consul
consul_server = consul.Consul(host='127.0.0.1', port=8500)
consul_kv = consul_server.kv.get(key='', recurse=True)
pupil
  • 318
  • 2
  • 16
0

You can use curl to retrieve the value for particular key.

curl \ <your consul url>/v1/kv/<yourkey>

I haven't used curl directly much but libraries which gives more flexibility to use consul api. I have used diplomat in this which is a very powerful and yet very simple to use, its written in ruby. For getting all key value pairs recursively I can use get method

Diplomat::Kv.get('/', recurse: true)
slashpai
  • 1,141
  • 7
  • 12
0

I have developed a cli to list all the keys and values and export options also https://github.com/amjad489/goconsul

Amjad Hussain Syed
  • 994
  • 2
  • 11
  • 23