diff --git a/README.rst b/README.rst index 917bf8f..3877aaa 100644 --- a/README.rst +++ b/README.rst @@ -7,6 +7,7 @@ NewRelic platform. Currently supported backend systems are: - Alternative PHP Cache - Apache HTTP Server - CouchDB +- Couchbase - Elasticsearch - HAProxy - Memcached @@ -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 diff --git a/docker/base/newrelic-plugin-agent.cfg b/docker/base/newrelic-plugin-agent.cfg index f957d04..3b7a316 100644 --- a/docker/base/newrelic-plugin-agent.cfg +++ b/docker/base/newrelic-plugin-agent.cfg @@ -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 diff --git a/etc/newrelic/newrelic-plugin-agent.cfg b/etc/newrelic/newrelic-plugin-agent.cfg index f957d04..3b7a316 100644 --- a/etc/newrelic/newrelic-plugin-agent.cfg +++ b/etc/newrelic/newrelic-plugin-agent.cfg @@ -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 diff --git a/newrelic_plugin_agent/plugins/__init__.py b/newrelic_plugin_agent/plugins/__init__.py index 98c5cb9..1a87a63 100644 --- a/newrelic_plugin_agent/plugins/__init__.py +++ b/newrelic_plugin_agent/plugins/__init__.py @@ -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', diff --git a/newrelic_plugin_agent/plugins/couchbase.py b/newrelic_plugin_agent/plugins/couchbase.py new file mode 100644 index 0000000..35c3f72 --- /dev/null +++ b/newrelic_plugin_agent/plugins/couchbase.py @@ -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)