I just did this
from elasticsearch import Elasticsearch
# you can use RFC-1738 to specify the url
# ... or specify common parameters as kwargs
es = Elasticsearch(
cloud_id="mycluster:sdfgsdfgdsfgdsfglvdsfgsdfgdsfgmNiM2JkNzRjNDY3JGIxZTUyOWEwNTBkNjRkODZhMzIxZTBhMjU3YjRlODhh",
http_auth=("elastic", "dsfgsdfgsdfgg"),
)
output = es.info(),
print(output, end=" ")
and it worked fine...
This also worked fine...
es = Elasticsearch(
cloud_id="mycluster:sdfgsdfgdsfgdsfgsdfgsdfgsdfgsdfgsdfgsdfgsdfgsdfgdsfgkODZhMzIxZTBhMjU3YjRlODhh",
api_key=('cew-IX0BKn301Oe9gPyz', '02I9MJ4OR2GdxYqY3I3cKA'),
remember this is NOT and Elastic Cloud API key it is an Elasticsearch API key which can only be created via and API call see here
POST /_security/api_key
{
"name": "my-api-key",
"expiration": "1d",
"role_descriptors": {
"role-a": {
"cluster": ["all"]
}
}
}
results
{
"id" : "cew-IX0BKn301Oe9gPyz",
"name" : "my-api-key",
"expiration" : 1637026684066,
"api_key" : "02I9MJ4OR2GdxYqY3I3cKA"
}
Please don't anyone worry those are invalid API keys