# curl --silent --request PUT elk:9200/_snapshot/repository-gcs?pretty --data '{"type":"gcs","settings":{"bucket":"repository-gcs","client":"digaweb"}}'
{
"error" : {
"root_cause" : [
{
"type" : "exception",
"reason" : "Error when loading Google Cloud Storage credentials file"
}
],
"type" : "repository_exception",
"reason" : "[repository-gcs] failed to create repository",
"caused_by" : {
"type" : "exception",
"reason" : "Error when loading Google Cloud Storage credentials file",
"caused_by" : {
"type" : "i_o_exception",
"reason" : "The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information."
}
}
},
"status" : 500
}
#
I'm NOT running elasticsearch inside of Google Compute Engine, so I defined environment variable GOOGLE_APPLICATION_CREDENTIALS , however still getting same error (see above):
# export GOOGLE_APPLICATION_CREDENTIALS=/digaweb-c819f0854eae.json
# echo $GOOGLE_APPLICATION_CREDENTIALS
/digaweb-c819f0854eae.json
#
# service elasticsearch restart
* Stopping Elasticsearch Server [ OK ]
* Starting Elasticsearch Server [ OK ]
#
You have two problems. First, the add command is for string settings. But GCS requires the entire file be added. Second, you are specifying the setting as digaweb, but that is not the setting name GCS looks for.
per @rjernst comment, I ran elasticsearch-keystore with "add-file" instead of "add --stdin":
# /opt/elasticsearch/bin/elasticsearch-keystore remove digaweb
# /opt/elasticsearch/bin/elasticsearch-keystore list
# /opt/elasticsearch/bin/elasticsearch-keystore add-file gcs.client.default.credentials_file digaweb-c819f0854eae.json
# echo $?
0
# /opt/elasticsearch/bin/elasticsearch-keystore list
gcs.client.default.credentials_file
# curl --silent --request PUT elk:9200/_snapshot/repository-gcs?pretty --data '{"type":"gcs","settings":{"bucket":"repository-gcs"}}'
{
"error" : {
"root_cause" : [
{
"type" : "exception",
"reason" : "Error when loading Google Cloud Storage credentials file"
}
],
"type" : "repository_exception",
"reason" : "[repository-gcs] failed to create repository",
"caused_by" : {
"type" : "exception",
"reason" : "Error when loading Google Cloud Storage credentials file",
"caused_by" : {
"type" : "i_o_exception",
"reason" : "The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information."
}
}
},
"status" : 500
}
#
While trying to solve my problem, which resulted in the same error message as above, I stumbled upon this page. This is what I did in order to solve it. When adding the key like so:
I apologize, I actually ran commands in GCE environment and that's why it worked (well, sort of)), however when I run curl command outside of Google Cloud environment, I'm still getting same error as I did before:
# curl --silent --request PUT elk:9200/_snapshot/repository-gcs?pretty -d '{"type": "gcs", "settings": {"bucket": "repository-gcs", "client": "default"}}'
{
"error" : {
"root_cause" : [
{
"type" : "exception",
"reason" : "Error when loading Google Cloud Storage credentials file"
}
],
"type" : "repository_exception",
"reason" : "[repository-gcs] failed to create repository",
"caused_by" : {
"type" : "exception",
"reason" : "Error when loading Google Cloud Storage credentials file",
"caused_by" : {
"type" : "i_o_exception",
"reason" : "The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information."
}
}
},
"status" : 500
}
# docker exec -it elk bash
# echo $GOOGLE_APPLICATION_CREDENTIALS
'/digaweb-c819f0854eae.json'
# /opt/elasticsearch/bin/elasticsearch-keystore list
gcs.client.default.credentials_file
#
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.