Skip to content

Commit 1eba68c

Browse files
author
Jeff Kramer
committed
add dynamic-version-awareness and 1.3.2 support to elasticsearch
1 parent 2b04b99 commit 1eba68c

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

elasticsearch/python_modules/elasticsearch.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,17 @@ def metric_init(params):
187187

188188
host = params.get('host', 'http://localhost:9200/')
189189

190-
version = params.get('version', '1.2')
191-
190+
result = json.load(urllib.urlopen(host))
191+
192+
host_version = result.get('version',{}).get('number') or "1.2"
193+
version = params.get('version', host_version)
194+
192195
m = re.match('(?P<major>\d+)\.(?P<minor>(\d+(\.\d+)*))', version)
193-
196+
194197
if m and m.group('major') == '0':
195198
url_cluster = '{0}_cluster/nodes/_local/stats?all=true'.format(host)
199+
elif m and m.group('major') == '1' and m.group('minor') == '3.2':
200+
url_cluster = '{0}_nodes/_local/stats'.format(host)
196201
else:
197202
url_cluster = '{0}_cluster/state/nodes'.format(host)
198203

0 commit comments

Comments
 (0)