Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ElasticHQ not connecting to Elasticsearch cluster #538

Open
asrar7787 opened this issue May 21, 2021 · 4 comments
Open

ElasticHQ not connecting to Elasticsearch cluster #538

asrar7787 opened this issue May 21, 2021 · 4 comments

Comments

@asrar7787
Copy link

asrar7787 commented May 21, 2021

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 
@Nexulo
Copy link

Nexulo commented Nov 15, 2021

No solution for this problem?

@chrisvoo
Copy link

chrisvoo commented Feb 9, 2022

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

@asrar7787
Copy link
Author

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

@alkampfergit
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants