You can use the REST API to get bucket statistics from Couchbase Server. Your request URL should be taken from the stats.uri property of a bucket response. By default this request returns stats samples for the last minute and for heavily used keys. You use provide additional query parameters in a request to get samplings of statistics over different time periods:
zoom: Determines level of granularity
and time period for statistics. Indicate one of the following
as a URI parameters: (minute | hour | day | week | month |
year). This indicates you want a sampling of statistics within
the last minute, hour, day, week, and so forth. If you
indicate 'zoom = minute' you will get 60 timestamps and
statistics from within the last minute. If you indicate week,
you will get 100 timestamps and statistics from the last week,
and so forth.
resampleForUI: Indicates the number
of samplings you want Couchbase Server to provide with bucket
statistics. Indicate 1 if you want 60 samplings of statistics.
haveTStamp: Request samplings that
are newer than the given timestamp. Specified in Unix epoch
time.
The following is an example request:
curl -u admin:password -v http://localhost:8091/pools/default/buckets/test/statsThe following shows the actual HTTP request:
GET /pools/default/buckets/test/stats HTTP/1.1 User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5 Host: localhost:8091 Accept: */*
The following is the HTTP response. For the sake of brevity, some of the JSON sampling is abbreviated:
HTTP/1.1 200 OK Content-Type: application/json Content-Length: nnn { "op": { "samples": { "hit_ratio": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], "ep_cache_miss_rate": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], ..... "samplesCount": 60, "isPersistent": true, "lastTStamp": 1292513777166.0, "interval": 1000 }, "hot_keys": [ { "name": "48697", "ops": 0.0009276437847866419 }, { "name": "8487", "ops": 0.0009276437847866419 }, { "name": "77262", "ops": 0.0009276437847866419 }, { "name": "58495", "ops": 0.0009276437847866419 }, { "name": "21003", "ops": 0.0009276437847866419 }, { "name": "26850", "ops": 0.0009276437847866419 }, { "name": "73717", "ops": 0.0009276437847866419 }, { "name": "86218", "ops": 0.0009276437847866419 }, { "name": "80344", "ops": 0.0009276437847866419 }, { "name": "83457", "ops": 0.0009276437847866419 } ] } }