Consul KV store endpoints

326 views
Skip to first unread message

Check Peck

unread,
Jul 13, 2020, 11:42:05 PM7/13/20
to consu...@googlegroups.com
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 purposes 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 a new key/value in Consul.
 2. Update value of existing key.
 3. Keep a watch on the existing key so that if the value changes then I get notified and it can show me the new value of that key.

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

image.png

I tried with the 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 a new key/value and keep a watch on the existing key through the command line as well?

Abhi

unread,
Jul 14, 2020, 10:05:07 AM7/14/20
to Consul
Hi 

The reason you are getting 404 is because the URL is in correct, you are using "vi" instead of v1. 

Here are the examples -   https://www.consul.io/api-docs/kv


Also how can I create a new key/value - https://www.consul.io/api-docs/kv

let me know if you have issues while using the api call 


keep a watch on the existing key through the command line as well - I did not find the API, may be someone will comment on this, but you can do this using consul CLI - https://www.consul.io/docs/commands/watch



 and keep a watch on the existing key through the command line as well?

Check Peck

unread,
Jul 14, 2020, 11:56:45 AM7/14/20
to consu...@googlegroups.com
Hi, Thanks a lot for finding a silly mistake in my call. Yeah I get the response now and it works fine.
Yeah I don't see API for watch command. I am not sure whether it is there.

Also I have few other questions and I wanted to clarify on it:
I need to integrate Consul with my .Net core application as I am working with C# so my confusion is -
  1.  Does consul provide http api's for everything and then you can write your own client to work with those `http apis` by integrating with http client? If yes, then it means we can make a http call from any http client and get the value of a key right? And also create a periodic check on a particular key to see if there is any change and if yes then download the latest value of that key (to replicate the watch scenario right?)
  2. Or does Consul have a client for each language available and I can use that client for all my use cases?

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/consul/issues
Community chat: https://gitter.im/hashicorp-consul/Lobby
---
You received this message because you are subscribed to the Google Groups "Consul" group.
To unsubscribe from this group and stop receiving emails from it, send an email to consul-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/consul-tool/c10cf0ed-6280-45eb-95f8-c412f8e1fd64o%40googlegroups.com.

Abhi

unread,
Jul 14, 2020, 12:02:10 PM7/14/20
to Consul
Glad I could help. 

So regarding your 2. Or does Consul have a client for each language available and I can use that client for all my use cases? - Here is list of Client Libraries & SDKs - https://www.consul.io/api-docs/libraries-and-sdks

Regarding your 1. will reply in detail soon

On Tuesday, July 14, 2020 at 8:56:45 AM UTC-7, Check Peck wrote:
Hi, Thanks a lot for finding a silly mistake in my call. Yeah I get the response now and it works fine.
Yeah I don't see API for watch command. I am not sure whether it is there.

Also I have few other questions and I wanted to clarify on it:
I need to integrate Consul with my .Net core application as I am working with C# so my confusion is -
  1.  Does consul provide http api's for everything and then you can write your own client to work with those `http apis` by integrating with http client? If yes, then it means we can make a http call from any http client and get the value of a key right? And also create a periodic check on a particular key to see if there is any change and if yes then download the latest value of that key (to replicate the watch scenario right?)
  2. Or does Consul have a client for each language available and I can use that client for all my use cases?

To unsubscribe from this group and stop receiving emails from it, send an email to consu...@googlegroups.com.

Abhi

unread,
Jul 15, 2020, 2:01:48 PM7/15/20
to Consul
Hi regarding your 1. 

 Does consul provide http api's for everything and then you can write your own client to work with those `http apis` by integrating with http client? If yes, then it means we can make a http call from any http client and get the value of a key right? 

Yes. It provides the API, you can look at different client libraries here https://www.consul.io/api-docs/libraries-and-sdks 

 also create a periodic check on a particular key to see if there is any change and if yes then download the latest value of that key (to replicate the watch scenario right?) - You mean continuously polling /making call to the API to check if changed ? I would still see you can get watch working. 

Also look at consul-template - https://github.com/hashicorp/consul-template


On Tuesday, July 14, 2020 at 8:56:45 AM UTC-7, Check Peck wrote:
Hi, Thanks a lot for finding a silly mistake in my call. Yeah I get the response now and it works fine.
Yeah I don't see API for watch command. I am not sure whether it is there.

Also I have few other questions and I wanted to clarify on it:
I need to integrate Consul with my .Net core application as I am working with C# so my confusion is -
  1.  Does consul provide http api's for everything and then you can write your own client to work with those `http apis` by integrating with http client? If yes, then it means we can make a http call from any http client and get the value of a key right? And also create a periodic check on a particular key to see if there is any change and if yes then download the latest value of that key (to replicate the watch scenario right?)
  2. Or does Consul have a client for each language available and I can use that client for all my use cases?

To unsubscribe from this group and stop receiving emails from it, send an email to consu...@googlegroups.com.

Blake Covarrubias

unread,
Jul 15, 2020, 5:50:59 PM7/15/20
to consu...@googlegroups.com
Hi,

Consul Template and the watch functionality use Blocking Queries (https://www.consul.io/api/features/blocking.html) under the hood to notify clients of changes in Consul. This functionality is supported by several API endpoints. Look for the “Blocking Queries” parameter in the API docs to see whether it's supported by a particular API.

Several of the third-party SDKs have support for blocking queries. You can also write your own code to utilize this in your app.

Blake Covarrubias

To unsubscribe from this group and stop receiving emails from it, send an email to consul-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/consul-tool/cac10ceb-be92-432a-8547-f594f76d397ao%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages