DEV Community

loading...

ElasticHQ Setup On Docker

Asrar
Updated on ・2 min read

ElasticHQ Setup On Docker

In this article, I am going to highlight what ElasticHQ is very briefly, its benefits and how we can install it using Docker.

ElasticHQ is a powerful GUI tool packed with tons of good features which can be used to make life easier and meaningful when using with Elasticsearch.

Benefits

Some of its most useful features are:

  • Indices, nodes, shards, document size can be seen visually.
  • Visual cluster health indicator.
  • Visually manage indices, nodes.
  • Includes a Rest API feature which can be used to retrieve information without using terminal and curl commands.
  • A powerful Query feature to make life much easier to search through Elasticsearch documents. This is really great to validate if a document has been saved or not.

Now let's see its installation process. We will install ElasticHQ using Docker. This guide is based on Mac, however the commands should be identical or similar on other platforms. This guide also assumes, you are using Elasticsearch cluster on Docker.

ElasticHQ Installation

  • Determine the Docker network which your Elasticsearch nodes are on. This is imperative to ensure both Elasticsearch cluster and ElasticHQ use the same Docker network.

  • In terminal run:
    docker run -d -p 5000:5000 --network elasticsearch -e HQ_DEFAULT_URL='http://es01:9200' -e HQ_ENABLE_SSL=False --name elastichq elastichq/elasticsearch-hq

  • Change Elasticsearch cluster URL HQ_DEFAULT_URL='http://es01:9200' and the
    --network elasticsearch to match yours.

  • If you are using Elasticsearch cluster using docker-compose, ensure to use the Elasticsearch master node's service name as it appears in docker-compose.yml.

Let's look at an example:

version: '3.1'

services:
  elasticsearch: #master node's service name
    image: elasticsearch
    container_name: elasticsearch_cluster
    environment:
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    ports:
      - 9200:9200
    volumes:
      - ./db:/usr/share/elasticsearch/data
  • For this recipe to work, our docker command would have been changed to: docker run -d -p 5000:5000 --network elasticsearch -e HQ_DEFAULT_URL='http://elasticsearch:9200' -e HQ_ENABLE_SSL=False --name elastichq elastichq/elasticsearch-hq

Otherwise ElasticHQ will not be able to connect to cluster.

This is an important point to remember!

  • Now, update Elasticsearch node's configuration file elasticsearch.yml by adding below :
http.cors.enabled : true
http.cors.allow-origin : "*"
http.cors.allow-methods : OPTIONS, HEAD, GET, POST, PUT, DELETE
  • This configuration file can be accessed in Elasticsearch Docker container. If you have multiple nodes you will need to add these in each node's configuration.

  • Adding these values will ensure ElasticHQ can communicate with each Elasticsearch node available on your cluster.

  • Restart each Elasticsearch node.

  • Restart ElasticHQ service:
    docker conatiner restart elastichq

  • ElasticHQ GUI is now accessible via localhost:5000. Make sure to enter the correct Elasticsearch service URL and choose correct Elasticsearch cluster on the main admin page.

By using ElasticHQ, hope you can reduce your all guess work and increase productivity.

Discussion (0)

Forem Open with the Forem app