Consul KV store endpoints - consul

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:
Create new key/value in Consul.
Update value of existing key.
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:
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?

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

Related

How to get notification for updated IP in grafana datasource?

I am using prometheus as datasource for the grafana dashboard. I am adding the Mesh IP as the URL of the default datasource. Whenever the grafana runs, it creates grafana.db which contains all the information related to datasource. I need to work in such a way that user can change the default URL of the datasource. Till now, everything works very well.
Now my problem is, when I try to change the IP of default datasource, and when I run the container again, it again picks the default URL instead of last saved URL in the grafana.db file. I want it to work in such a way that it should read default datasource IP from grafana.db if the file is available otherwise read it from default Mesh IP.
I can think of two different approaches for this:
Calling some queries using Postgres.
Get notified from GUI whenever URL is changed by the user and update that URL in the variable.
I am completely lost how to solve this problem. Anyone please help me how I can solve this problem using above mentioned approaches or any other one.
Thanks in advance.
The grafana.db resorts to the old default URL because the data is not being persisted across restarts.
For data persistence, you need to map Grafana to an external DB. Install another db outside docker and use the following link to map it to Grafana: database_configuration
Also look at provisioning

Nifi: How to read access/secret key for AWSCredentialsProviderControlerService independent of environment

We are currently set path of properties file which contains secret/access key for Credentials File for AWSCredentialsProviderControlerService . Issue, is we are changing properties path for prod and non prod each time we run nifi workflow. trying to come up no change on Configuration on Credential File path, so that access/secret key would be read regardless of prod and non prod. Since credential file wont support Nifi Expresion language, trying to make use of ACCESS KEY/SECRET properties ${ENV:equalsIgnoreCase("prod"):ifElse(${ACESS_PROD},${ACESS_NONPROD})} Issue we are facing, we are not able to store these access key/secret keys to the registry. Hence unable to implement this change. Is there any way to read access/secret key regardless of environment in Nifi. Curently we are using 1 property file for non prod nifi and 2nd property file for prod properties. In this set up, manually need to changed to credential file path when switching from prod to non prod. Trying to seamlessly work without changing path of credential file. Is there any way to make this happen?
enter image description here
The process that uses the AWSCredentialsProviderControlerService does not support param or variables, but the AWSCredentialsProviderControlerService "credential file" property supports "Parameters Context" as entries, make use of this for your solution.
Example:
Trigger something --> RouteOnAttribute --> If Prod (run executestreamcmd and change the Parameter Context Value to point to prod credfile) else if DEV(run executestreamcmd and change the Parameter Context Value to point to prod credfile) --> then run you AWS Processor.
You can use the toolkit client to edit the parameter context, or event nipyapi python module. It will not be fast tohu.

How do I get the same result of consul kv get -recurse with consul http api?

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?
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)
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)
I have developed a cli to list all the keys and values and export options also
https://github.com/amjad489/goconsul

Do not have the master key of Parse app

I know I should have done this before. But I didn't get a chance to host parse and now when I am trying to do it, it is asking to enter me master key, but I do not have it. I have parse channel name, client key, application id, javascript key. Is it possible to host a parse server using these keys only or is there any way to get master key now? Please help. Thank you in advance.
You define your own master key when you host a parse server. It can be anything you want.
If you mean you want to keep the existing master key from a parse.com app, there is no way to do this unless you have a record of it. For instance if you used it somewhere.

How to setup Cloud Coding on Parse Open Server using Heroku

I have looked everywhere but cannot seem to figure out how to setup cloud coding on the Parse Open Server using Heroku.
I see this link which tells me what to put in the Index.js and Main.js file: Implementing Cloud Code on Open Source Parse Server. However, I cannot seem to find those files. Nor can I find the "cloud" folder.
How do I find the cloud folder?
I created the Parse Server on MongoDB using the "Deploy to Heroku" link on this page: https://github.com/ParsePlatform/parse-server-example. After creating my application by filling out all the information, I ran the command heroku git:clone -a yourAppName to clone the application files. However, when I use the command I obtain a empty repository and get the following message in my terminal:
Cloning into 'hyv3-moja'...
warning: You appear to have cloned an empty repository.
So, how/where do I find the cloud folder with main.js? Did I miss any step in creating the Parse Server?
I also tried using the Parse Command Line. However, when I try to use the parse new command, it requires me to login to a Parse account. However, since Parse is going down, they are not accepting new accounts and I did not have an account before. Regardless, this seems like a deadend.
So can someone please explain to me how to set up Cloud Code?? I want to create a code that decrements a column in the database every second so it operates like a timer. Basically, I want my application to create objects on the database that last a certain amount of time chosen by the user. For this example, ill say 24 hours. So from the moment it is created, I want to decrement those 24 hours in the database. That way when a user of my application clicks to view the object, I translate the time remaining from the database and just output that value to the user to show how much time is remaining for the life of the object.

Resources