Skip to content

Commit

Permalink
add couchbase support
Browse files Browse the repository at this point in the history
this is a squash commit of all couchbase commits
from minodes/newrelic-plugin-agent:
- 33c9162
  fix JSON access
- 4e06957
  read basicStats from all couchbase buckets
- eb58aa6
  basicStats now per bucket sent to newrelic
- ede17dc
  add couchbase support

the original branch used in pull request #404 had a bunch
of garbage commits related to other plugins (nagiorelic).

i cleaned the unrelated stuff and squashed everything
to a single commit
  • Loading branch information
Gregor Zeitlinger authored and oryband committed Oct 27, 2015
1 parent fa9c481 commit 8160951
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ NewRelic platform. Currently supported backend systems are:
- Alternative PHP Cache
- Apache HTTP Server
- CouchDB
- Couchbase
- Elasticsearch
- HAProxy
- Memcached
Expand Down Expand Up @@ -298,6 +299,12 @@ Configuration Example
#username: foo
#password: bar

couchbase:
name: localhost
host: localhost
port: 8091
path: pools/default/buckets

elasticsearch:
name: clustername
host: localhost
Expand Down
6 changes: 6 additions & 0 deletions docker/base/newrelic-plugin-agent.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ Application:
# username: foo
# password: bar

#couchbase:
# name: localhost
# host: localhost
# port: 8091
# path: pools/default/buckets

#elasticsearch:
# name: Clustername
# host: localhost
Expand Down
6 changes: 6 additions & 0 deletions etc/newrelic/newrelic-plugin-agent.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ Application:
# username: foo
# password: bar

#couchbase:
# name: localhost
# host: localhost
# port: 8091
# path: pools/default/buckets

#elasticsearch:
# name: Clustername
# host: localhost
Expand Down
1 change: 1 addition & 0 deletions newrelic_plugin_agent/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
available = {
'apache_httpd': 'newrelic_plugin_agent.plugins.apache_httpd.ApacheHTTPD',
'couchdb': 'newrelic_plugin_agent.plugins.couchdb.CouchDB',
'couchbase': 'newrelic_plugin_agent.plugins.couchbase.Couchbase',
'edgecast': 'newrelic_plugin_agent.plugins.edgecast.Edgecast',
'elasticsearch':
'newrelic_plugin_agent.plugins.elasticsearch.ElasticSearch',
Expand Down
60 changes: 60 additions & 0 deletions newrelic_plugin_agent/plugins/couchbase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
"""
couchbase
"""

from newrelic_plugin_agent.plugins import base


class Couchbase(base.JSONStatsPlugin):

GUID = 'com.meetme.couchbase'

def add_datapoints(self, stats):
for bucket_data in stats:
bucket_name = bucket_data['name']
bucket_stats = bucket_data['basicStats']
if bucket_stats:
""" Example JSON
"basicStats":{
"quotaPercentUsed":7.548735046386719,
"opsPerSec":0,
"diskFetches":0,
"itemCount":2222,
"diskUsed":229366539,
"dataUsed":203511808,
"memUsed":79154224
}
"""
self.add_gauge_bucket_metric(
bucket_name, 'quotaPercentUsed', 'percent', bucket_stats['quotaPercentUsed']
)
self.add_gauge_bucket_metric(
bucket_name, 'opsPerSec', 'ops', bucket_stats['opsPerSec']
)
self.add_gauge_bucket_metric(
bucket_name, 'diskFetches', 'count', bucket_stats['diskFetches']
)
self.add_gauge_bucket_metric(
bucket_name, 'itemCount', 'count', bucket_stats['itemCount']
)
self.add_gauge_bucket_metric(
bucket_name, 'diskUsed', 'Byte', bucket_stats['diskUsed']
)
self.add_gauge_bucket_metric(
bucket_name, 'dataUsed', 'Byte', bucket_stats['dataUsed']
)
self.add_gauge_bucket_metric(
bucket_name, 'memUsed', 'Byte', bucket_stats['memUsed']
)

# Summary metrics
self.add_gauge_value('Summary/%s/quotaPercentUsed' % bucket_name, 'percent',
bucket_stats['quotaPercentUsed'],
min_val=0, max_val=0)
self.add_gauge_value('Summary/%s/diskUsed' % bucket_name, 'byte',
bucket_stats['diskUsed'])

def add_gauge_bucket_metric(self, bucket_name, metric_name, units, metric_value):
if metric_value:
self.add_gauge_value('%s/%s' % (bucket_name, metric_name), units, metric_value)

0 comments on commit 8160951

Please sign in to comment.