Consul crud operation commands for delete and get all - consul

I have consul entries in my kubernetes cluster. I need to perform CRUD operations. These are the commands I know, but I need to Get all and Delete and this has to be done with HTTP requests and not with consul cli.
GET - curl -k -X GET /?token=
GET ALL -
CREATE/PUT - curl -k --request PUT --data '' /?token=
DELETE -
can someone please help me to find those two empty commands?

I provided an answer here https://stackoverflow.com/a/61491161/12384224 on how you can retrieve all values from Consul's KV store.
Consul's KV Store API docs contain curl examples for creating and deleting a given key. Take a look at Consul's Transaction API documentation if you are looking for a way to create and delete keys en-masse.

Related

How can you tell if a solana node is synced?

I'm running a solana node using the solana-validator command (see Solana docs).
And I'd like to know if my validator is ready to connect to the http/rpc/ws port. What's the quickest way to do check to see if it's synced?
Currently, I'm using wscat to check to see if I can connect to the websocket, but am unable to. I'm not sure if that's because the node isn't setup right, or it's not synced, etc.
I know if I run solana gossip I should be able to see my IP in the list that populates... but is that the best way?
Run a curl command against your node for block height:
curl http://<IP>:<PORT> -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1, "method":"getBlockHeight"}'
And you'll get an output like:
{"jsonrpc":"2.0","result":105334870,"id":1}
Compare this to some other node, like a block explorer, and see if you're up to speed.
Take a look at solana catchup, which does exactly what you're asking for: https://docs.solana.com/cli/usage#solana-catchup

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:
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

YARN REST API returns startedTime and other fields as 0

When making calls to the YARN REST Api via curl, to get the jobs on the cluster, using:
curl --negotiate -u : http:<rm url>:<port>/ws/v1/cluster/apps?states=finished,failed,killed
In the resulting JSON, I get all the values but startedTime, finishedTime and elapsedTime have value 0.
N.B: On the YARN UI, these values are present, and also when using the cmd yarn application -status.
I checked on the API documentation, and I couldn't find a parameter to force the fields returned, is it because of some parameter that I can't get these values?
I'd answer my question in case someone has the same issue.
After more research, I found that the access to some metrics via the YARN REST API in a Kerberized cluster is restricted via ACLs, only the user who lunched the job and the admin users are able to access these metrics.
To bypass this, we ought to:
yarn.admin.acl=false
or
yarn.scheduler.capacity.root.acl_administer_jobs=*
yarn.scheduler.capacity.root.acl_administer_queue=*
Source: https://community.hortonworks.com/questions/91199/yarn-web-interface-reporting-0-for-many-metrics-fo.html

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

get elasticsearch schema via commandline tool

I am trying to get up to speed on an elasticsearch implementation on a project. How can I see the data that is on the cluster? Is there a commandline tool that gives me information on the schema?
To get schema:
curl -XGET 'http://loadtest-appserver1:9200/myIndex/_mapping'
See Elasticsearch Api Doc
Try using ElasticSearch Head
http://mobz.github.io/elasticsearch-head/
It's a great tool when peeking in your index and it's meta data (such as the schema) to find out what's going on.
Also it's HTML5/REST based, so you can take a look in your browser at the commands it sends to your cluster and use those with command line CURL if needed.

Resources