Skip to content

Commit

Permalink
Do not dispatch 0 value for non existent stats (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
asuresh4 authored Mar 7, 2019
1 parent c11d5c0 commit 9a8894b
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions elasticsearch_collectd.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,13 +948,7 @@ def init_stats(self):
def lookup_node_stat(self, stat, json):
node = json['nodes'].keys()[0]
val = dig_it_up(json, self.node_stats_cur[stat].path % node)

# Check to make sure we have a valid result
# dig_it_up returns False if no match found
if not isinstance(val, bool):
return int(val)
else:
return None
return val

def fetch_stats(self):
"""
Expand Down Expand Up @@ -1104,12 +1098,6 @@ def parse_thread_pool_stats(self, json, stats):
if self.detailed_metrics is True or name in self.defaults:
node = json['nodes'].keys()[0]
result = dig_it_up(json, key.path % node)
# Check to make sure we have a valid result
# dig_it_up returns False if no match found
if not isinstance(result, bool):
result = int(result)
else:
result = None

self.dispatch_stat(result, name, key,
{'thread_pool': pool})
Expand Down Expand Up @@ -1144,7 +1132,7 @@ def dispatch_stat(self, result, name, key, dimensions=None):
d=dimensions,
r=result))
if result is None:
log.warning('Value not found for %s' % name)
log.debug('Value not found for %s' % name)
return

# If we failed to get the cluster name and do not have a config
Expand Down Expand Up @@ -1210,7 +1198,7 @@ def dig_it_up(obj, path):
path = path.split('.')
return reduce(lambda x, y: x[y], path, obj)
except:
return False
return None


# The following classes are there to launch the plugin manually
Expand Down

0 comments on commit 9a8894b

Please sign in to comment.