Basic authentication with hey tool fails - elasticsearch

I have an elasticsearch cluster which I can hit as follows:
▶ curl -k https://localhost:9200 -u username:password
{
"name" : "elasticsearch-sample-es-master-1",
"cluster_name" : "elasticsearch-sample",
"cluster_uuid" : "XXXXXXXXXXXXXXXXXXX",
"version" : {
"number" : "7.11.0",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "8ced7813d6f16d2ef30792e2fcde3e755795ee04",
"build_date" : "2021-02-08T22:44:01.320463Z",
"build_snapshot" : false,
"lucene_version" : "8.7.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
(I have port-forwarded the service locally)
However when hitting it with hey
hey https://localhost:9200 -a username:password
Status code distribution:
[401] 200 responses
Any ideas?

You can try the following
hey https://username:password#localhost:9200
That works!
Note: There are open issues in the official hey repository, https://github.com/rakyll/hey/issues/150

Related

Problem when running elastic search on windows 10

when i am running elastic search on windows 10 , i can not open elastic portal in the local host and i got this message :
{
"name" : "ISBUS-PC02",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "FE38HTACR2evmiVFD7ciag",
"version" : {
"number" : "8.6.0",
"build_flavor" : "default",
"build_type" : "zip",
"build_hash" : "f67ef2df40237445caa70e2fef79471cc608d70d",
"build_date" : "2023-01-04T09:35:21.782467981Z",
"build_snapshot" : false,
"lucene_version" : "9.4.2",
"minimum_wire_compatibility_version" : "7.17.0",
"minimum_index_compatibility_version" : "7.0.0"
},
"tagline" : "You Know, for Search"
}
nothing, because this is the last issue i stucked on.
This JSON you provided means Elasticsearch is up and running perfectly fine. You can note in the JSON response, Elasticsearch cluster name, version, build type and other information is also provided.
{
"name": "ISBUS-PC02",
"cluster_name": "elasticsearch",
"cluster_uuid": "FE38HTACR2evmiVFD7ciag",
"version":
{
"number": "8.6.0",
"build_flavor": "default",
"build_type": "zip",
"build_hash": "f67ef2df40237445caa70e2fef79471cc608d70d",
"build_date": "2023-01-04T09:35:21.782467981Z",
"build_snapshot": false,
"lucene_version": "9.4.2",
"minimum_wire_compatibility_version": "7.17.0",
"minimum_index_compatibility_version": "7.0.0"
},
"tagline": "You Know, for Search"
}
You don't have to worry, your Elasticsearch cluster is up and running and you can execute other requests.

Could not validate a connection to Elasticsearch. Unknown 401 error from Elasticsearch null

{
"name" : "DESKTOP-BNTBBBG",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "DlRfjfPlRg69wUBRfy3kKQ",
"version" : {
"number" : "8.1.3",
"build_flavor" : "default",
"build_type" : "zip",
"build_hash" : "39afaa3c0fe7db4869a161985e240bd7182d7a07",
"build_date" : "2022-04-19T08:13:25.444693396Z",
"build_snapshot" : false,
"lucene_version" : "9.0.0",
"minimum_wire_compatibility_version" : "7.17.0",
"minimum_index_compatibility_version" : "7.0.0"
},
"tagline" : "You Know, for Search"
}
But When running this command
php bin/magento setup:install --base-url="http://versionup.magento.com" --db-host="localhost" --db-name="magento2" --db-user="magento2" --db-password="magento2" --admin-firstname="admin" --admin-lastname="admin" --admin-email="user#example.com" --admin-user="admin" --admin-password="Admin#123456" --language="en_US" --currency="USD" --timezone="America/Chicago" --use-rewrites="1" --backend-frontname="admin" --search-engine=elasticsearch7 --elasticsearch-host="localhost" --elasticsearch-port=9200
Could not validate a connection to Elasticsearch. Unknown 401 error from Elasticsearch null
i have the same problem, but now it's fixed.
make sure you enable xpack.security.http.ssl on elasticsearch.yml. because I disable it before.
then change the host to:
--elasticsearch-host="https://localhost"
then add more options to your command for authentication:
--elasticsearch-enable-auth=true --elasticsearch-username="elastic" --elasticsearch-password="your password"

Unexpected JSON event 'VALUE_FALSE' instead of '[KEY_NAME, VALUE_STRING]' when calling client.indices().getTemplate()

I am writing some code to manage ElasticSearch templates. When running the code snippet below I am getting
co.elastic.clients.json.UnexpectedJsonEventException: Unexpected JSON event 'VALUE_FALSE' instead of '[KEY_NAME, VALUE_STRING]'
(See https://discuss.elastic.co/t/java-unexpected-json-event-value-true-instead-of-key-name-value-string/295740 for full callstack - too long to paste here)
Code
// simplified code for demo this issue, but does reproduce.
private static stackoverflowIssue(ElasticsearchClient client) {
GetIndexTemplateResponse r = client.indices().getIndexTemplate();
}
ES info:
{
"name" : "1ec11a1cb3c9",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "7e0zLYxmQsST0EllSlc_KA",
"version" : {
"number" : "7.16.2",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "2b937c44140b6559905130a8650c64dbd0879cfb",
"build_date" : "2021-12-18T19:42:46.604893745Z",
"build_snapshot" : false,
"lucene_version" : "8.10.1",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
ES dependency in pom.xml
<dependency>
<groupId>co.elastic.clients</groupId>
<artifactId>elasticsearch-java</artifactId>
<version>7.16.3</version>
</dependency>
<dependency>
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
<version>2.0.1</version>
</dependency>
Please help, thanks!
This is a valid issue tracked by
https://github.com/elastic/elasticsearch-java/issues/139

X-Pack 401 Logstash cant connect to Elasticsearch

I changed JVM heap sized and Logstash cant connect to Elasticsearch, after restarting Elasticsearch
logstash.yml
xpack.monitoring.enabled: true
xpack.monitoring.elasticsearch.hosts: ["es:9200"]
xpack.monitoring.elasticsearch.username: logstash_system
xpack.monitoring.elasticsearch.password: pass
logs by Logstash
[WARN ][logstash.outputs.elasticsearch][main] Attempted to resurrect connection to dead ES instance, but got an error. {:url=>"http://es:9200/", :error_type=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::BadResponseCodeError, :error=>"Got response code '401' contacting Elasticsearch at URL 'http://es:9200/'"}
curl from logstash to es with same credentials
logstash: curl -ulogstash_system es:9200
Enter host password for user 'logstash_system':
{
"name" : "elasticsearch",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "",
"version" : {
"number" : "7.5.0",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "",
"build_date" : "2019-11-26T01:06:52.518245Z",
"build_snapshot" : false,
"lucene_version" : "8.3.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}

Elasticsearch showing error 406 when inserting

Just installed ElasticSearch on my mac (brew install elasticsearch).
Then started it with: brew services start elasticsearch.
I can see it is running:
curl localhost:9200
{
"name" : "84ucGje",
"cluster_name" : "elasticsearch_dnk306",
"cluster_uuid" : "yU6wdZpJT_-1OvaFf7l7Ug",
"version" : {
"number" : "6.5.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "816e6f6",
"build_date" : "2018-11-09T18:58:36.352602Z",
"build_snapshot" : false,
"lucene_version" : "7.5.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
When I try to add some index to it - it fails with 406 error:
curl -XPOST localhost:9200/test/1 -d '{"title":"Hello world"}'
{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}
What do I need to do to make this work?
Thanks.

Resources