Skip to content

Commit

Permalink
- Fix for node roles in ES v7.
Browse files Browse the repository at this point in the history
  • Loading branch information
royrusso committed Apr 14, 2019
1 parent f80f8c5 commit df73e57
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Simplified Monitoring and Management for ElasticSearch clusters.

## Key Features

* Works with 2.x, 5.x, 6.x and current versions of Elasticsearch.
* Works with 2.x, 5.x, 6.x, 7.x and current versions of Elasticsearch.
* Monitor **many** clusters at once.
* Monitor Nodes, Indices, Shards, and general cluster metrics.
* Create and maintain Elasticsearch Indices.
Expand Down
4 changes: 2 additions & 2 deletions elastichq/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class TestSettings(BaseSettings):
# static
HQ_SITE_URL = 'http://elastichq.org'
HQ_GH_URL = 'https://github.com/ElasticHQ/elasticsearch-HQ'
API_VERSION = 'v3.5.0'
API_VERSION = 'v3.5.1'
ES_V2_HOST = '127.0.0.1'
ES_V2_PORT = '9200'
ES_V5_HOST = '127.0.0.1'
Expand Down Expand Up @@ -124,7 +124,7 @@ class ProdSettings(BaseSettings):
# static
HQ_SITE_URL = 'http://elastichq.org'
HQ_GH_URL = 'https://github.com/ElasticHQ/elasticsearch-HQ'
API_VERSION = '3.5.0'
API_VERSION = '3.5.1'
SERVER_NAME = None

# cluster settings: specific settings for each cluster and how HQ should handle it.
Expand Down
22 changes: 18 additions & 4 deletions elastichq/service/NodeService.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from .ConnectionService import ConnectionService
from ..globals import REQUEST_TIMEOUT
import jmespath


class NodeService:
Expand All @@ -13,19 +12,30 @@ def get_node_stats(self, cluster_name, nodes_list=None, request_timeout=REQUEST_

return node_stats


def get_node_info(self, cluster_name, nodes_list=None):
connection = ConnectionService().get_connection(cluster_name)

return connection.nodes.info(node_id=nodes_list, metric="_all", request_timeout=REQUEST_TIMEOUT)
node_infos = connection.nodes.info(node_id=nodes_list, metric="_all", request_timeout=REQUEST_TIMEOUT)

# breaking change == miserable hack. v7 is missing the settings block that used to contain master/data designations
if connection.version.startswith("7"):
for node_id in node_infos['nodes']:
node_settings = node_infos.get("nodes").get(node_id)['settings']
node_roles = node_infos.get("nodes").get(node_id)['roles']
if 'master' in node_roles:
node_settings['node']['master'] = True
if 'data' in node_roles:
node_settings['node']['data'] = True

return node_infos

def get_node_cat(self, cluster_name, flags="*", request_timeout=REQUEST_TIMEOUT):
connection = ConnectionService().get_connection(cluster_name)
# "id,m,n,u,role,hp,ip,disk.avail,l"
cat_nodes = connection.cat.nodes(format="json", h=flags, full_id=True, request_timeout=request_timeout)
return cat_nodes

def get_node_summary(self, cluster_name, node_ids=None):
def get_node_summary(self, cluster_name):
"""
Given a node(s), consolidates data from several Node APIs in a human-readable format.
:param cluster_name:
Expand Down Expand Up @@ -72,6 +82,10 @@ def get_node_summary(self, cluster_name, node_ids=None):
node.update({"is_data_node": True})
else:
node.update({"is_data_node": False})
if cnode['role'] == 'i' or 'i' in cnode['role']:
node.update({"is_ingest_node": True})
else:
node.update({"is_ingest_node": False})

nodes.append(node)
return nodes
2 changes: 0 additions & 2 deletions elastichq/static/commons.110e62edca51cd300982.js

This file was deleted.

2 changes: 0 additions & 2 deletions elastichq/static/main.110e62edca51cd300982.js

This file was deleted.

4 changes: 2 additions & 2 deletions elastichq/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<head>
<meta charset="UTF-8">
<title>Elastic Search - HQ</title>
<link href="static/app.bundle.css?110e62edca51cd300982" rel="stylesheet"></head>
<link href="static/app.bundle.css?13996294131c5f6bc3a7" rel="stylesheet"></head>
<body ng-app="eshq" ng-strict-di>
<eshq-top-nav></eshq-top-nav>
<div class="container-fluid">
<div ui-view></div>
</div>
<eshq-footer></eshq-footer>
<script type="text/javascript" src="static/commons.110e62edca51cd300982.js?110e62edca51cd300982"></script><script type="text/javascript" src="static/main.110e62edca51cd300982.js?110e62edca51cd300982"></script></body>
<script type="text/javascript" src="static/commons.13996294131c5f6bc3a7.js?13996294131c5f6bc3a7"></script><script type="text/javascript" src="static/main.13996294131c5f6bc3a7.js?13996294131c5f6bc3a7"></script></body>
</html>

0 comments on commit df73e57

Please sign in to comment.