elasticsearch-HQ icon indicating copy to clipboard operation
elasticsearch-HQ copied to clipboard

ElasticHQ not connecting to Elasticsearch cluster

Open asrar7787 opened this issue 3 years ago • 4 comments

General information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Mac OS Big Sur
  • ElasticHQ Version: latest master branch
  • Elasticsearch Version: 7.6.2
  • Python version (ignore is using docker image): 3.6.6
  • Browser Vendor and Version (if applicable):

Issue Description

I installed Elasticsearch v7.6.2 with via brew and I am starting the elasticsearch cluster with one node using CLI command instead of using brew's service start command.

I can curl and see the elasticsearch cluster health is OK as below:

curl -X GET http://localhost:9200/_cluster/health\?\=pretty

{
  "cluster_name" : "elasticsearch",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 0,
  "active_shards" : 0,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}

I cloned ElasticHQ's github repo's master branch and followed the guide here - https://docs.elastichq.org/installation.html#install-elastichq

After staring the ElasticHQ service I can see the main page at http://localhost:5000. But when I refresh the page it just keeps showing Found 0 clusters

And if I enter the cluster address http://localhost:9200/ and click Connect it shows the following error in browser console:

angular.js:12836 POST http://localhost:5000/api/clusters/_connect 500 (INTERNAL SERVER ERROR)
(anonymous) @ angular.js:12836
(anonymous) @ angular.js:12563
(anonymous) @ angular.js:12311
(anonymous) @ angular.js:17160
(anonymous) @ angular.js:17208
$digest @ angular.js:18342
$apply @ angular.js:18640
(anonymous) @ angular.js:27468
Ft @ angular.js:3785
n @ angular.js:3773
home.controller.js:82 

ERR:  
{data: {…}, status: 500, config: {…}, statusText: "INTERNAL SERVER ERROR", headers: ƒ, …}
config:
data: {ip: "localhost", port: "9200", username: "", password: "", use_ssl: false}
headers: {Accept: "application/json, text/plain, */*", Content-Type: "application/json;charset=utf-8"}
jsonpCallbackParam: "callback"
method: "POST"
paramSerializer: ƒ (e)
timeout: l {$$state: {…}}
transformRequest: [ƒ]
transformResponse: [ƒ]
url: "api/clusters/_connect"
__proto__: Object
data: {message: "Internal Server Error"}
headers: ƒ (n)
status: 500
statusText: "INTERNAL SERVER ERROR"
xhrStatus: "complete"
__proto__: Object

No matter what I am doing I am not able to get the ElasticHQ to connect to Elasticsearch cluster.

Any suggestions/advice would be great help.

Source Code / Logs

Here's my node configs with CORS configs at the bottom:

#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: elasticsearch
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
node.max_local_storage_nodes: 1

node.master: true 
node.data: true
node.ingest: true 
search.remote.connect: false
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /usr/local/var/lib/elasticsearch/
#
# Path to log files:
#
path.logs: /usr/local/var/log/elasticsearch/
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9301"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
# ES v7.x does not need this config
#discovery.zen.minimum_master_nodes: 1
#
# For more information, consult the zen discovery module documentation.
#
discovery.find_peers_interval: 1s

# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true

http.cors.enabled : true
http.cors.allow-origin : "*"
http.cors.allow-methods : OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers : X-Requested-With,X-Auth-Token,Content-Type,Content-Length

cluster.initial_master_nodes:
  - node-1

Here's the application.log details:

2021-05-21 02:44:01,231 	 ERROR 	 elastichq 	 exceptions._request_wrapper:37 	 Oops! Something bad happened.
Traceback (most recent call last):
  File "/Users/asrar/Sites/test/elk_artifacts/elasticsearch-HQ-master/elastichq/common/exceptions.py", line 29, in _request_wrapper
    return functor(*args, **kwargs)
  File "/Users/asrar/Sites/test/elk_artifacts/elasticsearch-HQ-master/elastichq/api/clusters.py", line 104, in post
    params.update(json_data)
TypeError: cannot convert dictionary update sequence element #510 

asrar7787 avatar May 21 '21 01:05 asrar7787

No solution for this problem?

maisen20 avatar Nov 15 '21 07:11 maisen20

You should launch both ElasticSearch and ElasticHQ under the same network, for example:

docker network create elastic

docker run --name Elastic –net elastic  --privileged=true --restart=always \
-p 9200:9200 -p 9300:9300 \
-v ~/apps/docker/elasticsearch/data:/usr/share/elasticsearch/data \
-v ~/apps/docker/elasticsearch/config:/usr/share/elasticsearch/config \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms512m -Xmx1024m" \
-d docker.elastic.co/elasticsearch/elasticsearch:7.15.1

docker run -d -p 5000:5000 –net elastic \
 -e HQ_DEFAULT_URL='http://elastic:9200' \
 -e HQ_ENABLE_SSL=False \
 --name elastichq elastichq/elasticsearch-hq

chrisvoo avatar Feb 09 '22 15:02 chrisvoo

Is there any way to connect to ElasticSearch installed on host as opposed to docker container?

asrar7787 avatar Feb 09 '22 15:02 asrar7787

I'm using http://host.docker.internal:9200 and it works like a charm. Link to official documentation

alkampfergit avatar Mar 10 '23 09:03 alkampfergit