Skip to content

Commit

Permalink
add thread pool stats
Browse files Browse the repository at this point in the history
This is a merge of 3b123da from phobos182/collectd-elasticsearch into
wyattwalter/collectd-elasticsearch since the upstream PR phobos182#13 was never merged
  • Loading branch information
jloomis authored and nathanhruby committed Sep 9, 2016
1 parent 4be6fe0 commit 7977403
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ def configure_callback(conf):

log_verbose('Configured with host=%s, port=%s' % (ES_HOST, ES_PORT))


def fetch_url(url):
try:
result = json.load(urllib2.urlopen(url, timeout=10))
Expand All @@ -208,16 +209,25 @@ def fetch_stats():
version = server_info['version']['number']

if StrictVersion(version) >= StrictVersion('1.0.0'):
ES_URL = base_url + '_nodes/_local/stats/transport,http,process,jvm,indices,breaker'
ES_URL = base_url + '_nodes/_local/stats/transport,http,process,jvm,indices,breaker,thread_pool'
STATS_CUR = dict(STATS.items() + STATS_ES1X.items())
if StrictVersion(version) >= StrictVersion('1.4.0'):
STATS_CUR = dict(STATS_CUR.items() + STATS_ES14.items())
else:
STATS_CUR = dict(STATS_CUR.items() + STATS_ES13.items())
else:
ES_URL = base_url + '_cluster/nodes/_local/stats?http=true&process=true&jvm=true&transport=true'
ES_URL = base_url + '_cluster/nodes/_local/stats?http=true&process=true&jvm=true&transport=true&thread_pool=true'
STATS_CUR = dict(STATS.items() + STATS_ES09.items())

# add info on thread pools
for pool in ['generic', 'index', 'get', 'snapshot', 'merge', 'optimize', 'bulk', 'warmer', 'flush', 'search', 'refresh']:
for attr in ['threads', 'queue', 'active', 'largest']:
path = 'thread_pool.{0}.{1}'.format(pool, attr)
STATS_CUR[path] = Stat("gauge", 'nodes.%s.{0}'.format(path))
for attr in ['completed', 'rejected']:
path = 'thread_pool.{0}.{1}'.format(pool, attr)
STATS_CUR[path] = Stat("counter", 'nodes.%s.{0}'.format(path))

result = fetch_url(ES_URL)

ES_CLUSTER = result['cluster_name']
Expand Down

0 comments on commit 7977403

Please sign in to comment.