Reads a Couchbase's bucket metadata and generates a report with statistics about stored items. The keys are grouped using a regex and for each group calculates:
- count
- average seconds left for expiration
- stardard deviation of seconds left for expiration
Expired items are discriminated because couchbase removes expired items at maintenance intervals.
- Add a view in the bucket with the following code:
- Go to Couchbase Console (Web UI) >
Views
>Create Development View
- Enter a
Design Document Name
andView Name
- Enter the following code:
function (doc, meta) { emit(meta.id, meta); }
- Save
- Go to Couchbase Console (Web UI) >
- Add config section
<configSections> <section name="couchbaseItemsStats" type="CouchbaseItemsStats.ConfigSection, CouchbaseItemsStats" /> </configSections> <couchbaseItemsStats viewDesignName="dev_Keys" viewName="Metadata" keyPrefixRegex="^(CacheContext_)?[^_]+" />
viewDesignName
: Design document/view name to consume.viewName
: View name to consume.keyPrefixRegex
: A regex used to extract the prefix from each key. It's used in grouping function.
- Obtain the stats:
var couchbaseClient = new CouchbaseClient(); var client = new StatsClient(couchbaseClient); var stats = client.GetStats();
- Edit settings in config file
<couchbase>
: Bucket connection.<couchbaseItemsStats>
: Lib config (see previous section).reportFormat
: Format used to store in the report. Onlyjson
is suppported by now.reportFilePath
: File path used to store the report.
- Run the .exe and the report file will be generated