Skip to content

Commit

Permalink
Add ElasticSearch plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
John Watson committed Oct 29, 2011
1 parent d644ade commit b91ebdc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions elasticsearch.py
@@ -0,0 +1,17 @@
import json
import requests
from porkchop.plugin import PorkchopPlugin

class ElasticSearchPlugin(PorkchopPlugin):
def get_data(self):
stats_url = self.config.get('elasticsearch', {}).get('stats_url',
'http://localhost:9200/_cluster/nodes/_local/stats')

raw_stats = json.loads(requests.get(stats_url).content)

# raw_stats['nodes'][<HASH>]
# The <HASH> is generated at server start and since it is the only key
# just list keys and grab the first one
stats = { raw_stats['cluster_name']: raw_stats['nodes'][raw_stats['nodes'].keys()[0]] }

return stats

1 comment on commit b91ebdc

@ohlol
Copy link
Contributor

@ohlol ohlol commented on b91ebdc Oct 29, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should just do return {raw_stats ...} here

Please sign in to comment.