diff --git a/elasticsearch/python_modules/elasticsearch.py b/elasticsearch/python_modules/elasticsearch.py index 2aa9643d..405fb652 100755 --- a/elasticsearch/python_modules/elasticsearch.py +++ b/elasticsearch/python_modules/elasticsearch.py @@ -187,12 +187,20 @@ def metric_init(params): host = params.get('host', 'http://localhost:9200/') - version = params.get('version', '1.2') - + try: + result = json.load(urllib.urlopen(host)) + except (ValueError, IOError): + result = {} + + host_version = result.get('version',{}).get('number') or "1.2" + version = params.get('version', host_version) + m = re.match('(?P\d+)\.(?P(\d+(\.\d+)*))', version) - + if m and m.group('major') == '0': url_cluster = '{0}_cluster/nodes/_local/stats?all=true'.format(host) + elif m and m.group('major') == '1' and m.group('minor') == '3.2': + url_cluster = '{0}_nodes/_local/stats'.format(host) else: url_cluster = '{0}_cluster/state/nodes'.format(host)