Simple? Where's the URL to query elastic cloud instance?

A hopefully simple question:
Where is the URL to query an elastic cloud instance for a given deployment?
The docs say to always use api dot elastic-cloud dot com/api/v1/deployments
but this doesn't appear to work for simply querying elastic.
Can anyone help? Thanks!

Hi @midi-man and welcome to the community!

the URL that you provided will get you a list of your deployments.
What you want to use is the "cloud_id".

it will look something like my_fancy_deployment:dXMtZWFzdDQuasdfZ2NwHLfWmVsYXNB0faWJMtY2fxvdWQuYP29stOdjLQf0MyQ2NTE4MMGIzMjVhOGM0ZTfBjOGIzYTs...",
you can also get the cloud_id when you log into the cloud management and "manage" your deployment:

Which client are you using to connect?

Each client has a way to connect to a cloud_id, this tells the client how to route the traffic.

Then you can use either an API Key that you generate or a username/password to authenticate.

For example, if you were connecting with Beats or Logstash, you can review:

Checking on your client, should give you more examples as well:

Hi @midi-man welcome to the community! And thanks for using elastic cloud!

That is to access the Elastic Cloud Console API for Organization admin not and actually to elasticsearch cluster

The actual endpoint to elasticsearch in the picture above is the Copy endpoint right next to the Elasticsearch logo

Thanks for your replies.

Which client are you using to connect?
I am using 'plain vanilla' https (unirest in this case). I'm not using an elastic client.

Yes, I have used the 'Copy endpoint' for the base url, however this fails with errors like 'No handler for 'blah' (I've tried a number of conventions for 'blah').

Here's an example curl:

curl -H "Content-Type:application/json" -H "Authorization: ApiKey aMaDeUpApIKeY==" -d"{"query": {"match_all":{}}}" h t t p s : // dot com/api/v1/testindex*/_search

(I've also tried various combinations with clusterid etc)

I would have thought the first thing someone would do after setting up elastic cloud would be to search on some test data. Is there some documentation somewhere that shows how elastic cloud differs from on-prem elastic? (I've been using elastic for many years - not sure why cloud deployment is so different)

Any help much appreciated!

I managed to get this to work.

For anyone running into elasticsearch on cloud issues, maybe this will help...

The documentation that talks about ApiKey - this is for deployment stuff only...not elastic. If you use it in an Authorization header during a _search (or any other elastic rest request) it will fail.

Instead, use basic auth - i.e. username:password as specified when your elastic cloud was setup - something like:
user: elastic
password: sfw6876368we376dywe7e (only shown once at creation time so definitely save it!)

For production
I would STRONGLY suggest changing this password to something MUCH stronger than what's generated. It seems the username is always 'elastic' (maybe?), so the password is the only thing between your data and the outside world.

The steps above then works in the same way stepthenb mentioned (use 'Copy endpoint' for your deployment endpoint), or use eMitch's CloudID technique if you're using an elastic client (like beats or logstash).

Thumbs up to eMitch and stepthenB for their help.

Happiness to all!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.