Posted on by & filed under Content - Highlights and Reviews, Web Development.

In a previous piece titled The Technology Behind Couchbase I described the technology that underpins the functionality of the Couchbase Server 1.8 and the forthcoming Couchbase Server 2.0. In this post, I will show you how to better monitor your Couchbase Server.

Couchbase Server has a great web-based UI that provides you with information on the status of your clusters, individual nodes, and individual buckets. All of the detail is provided as handy graphs that show you a visual, and historical, representation of how your server has been working under load.

Sometimes, though, you want to script and react to changes without having to physically watch the stats all the time. The entire administration stack within Couchbase Server is also exposed through a REST-based API, making it easy to pull information out quickly.

To connect, you need to send queries to the hostname or IP address on port 8091, optionally supplying the username and password if you want to change a setting.

For example, to get the basic information about the buckets in your server:

You can just use curl to access that URL on the command line if you wish:

Or you can use any URL-based solution from within your desired language.

The response is a JSON document with a lot of detail:

The main content is the pools section at the end of the listing. It tells you the URLs required for accessing and controlling the specific storage bucket.

Watching for key Stats

Statistics are exposed at a number of levels, including for the whole cluster and for individual buckets within the cluster. To get cluster statistics, access the /pools/stats URL, and for bucket specific stats, use /pools/BUCKET/stats.

To get the absolute best performance out of Couchbase, make sure that your data is available in RAM, and that it is not being loaded from disk. There are a few stats you can monitor, but a straightforward way is to look at the mem_used stat for a bucket. This will tell you how much memory is being used by the bucket, which you can compare to the allocated memory.

Another useful stat is ep_tmp_oom_errors, which reports how many times a client has tried to store data and received the temporary out of memory error. This would indicate that Couchbase has had to write data from RAM to disk to make room for the new data.

Finally, the disk write queue statistics will show you how busy your server is writing data to disk. This number shouldn’t keep increasing; if it does, it indicates that your cluster is unable to keep up with the amount of data being stored. You can monitor this by watching the ep_queue_size and ep_flusher_todo stats.

One way to monitor this and spot major changes is to use the watch with cbstats command, which is a wrapper around the REST API. For example, the line below will start a watcher that highlights differences of the main stats covered above:

Alternatively, you can write a quick tool in your favourite language to access the URL and extract the information from the returned JSON. You can then automatically notify yourself with whatever tool (SMS, twitter, etc.) that you want and keep an eye on your Couchbase Cluster.

These tips should help you monitor your Couchbase Server.

Safari Books Online has the content you need

Check out these Couchbase and CouchDB books available from Safari Books Online:

CouchDB is a new breed of database for the Internet, geared to meet the needs of today’s dynamic web applications. With Getting Started with CouchDB, you’ll learn how CouchDB’s simple model for storing, processing, and accessing data makes it ideal for the type of data and rapid response users now demand from your applications—and how easy CouchDB is to set up, deploy, maintain, and scale.
Learn how to create MapReduce views in CouchDB that let you query the document-oriented database for meaningful data. With Writing and Querying MapReduce Views in CouchDB, you’ll get step-by-step instructions and lots of sample code to create and explore several MapReduce views, using an example database you construct.
Scaling CouchDB is a practical guide to web developers who need to scale their CouchDB database instances. The basic concepts behind CouchDB’s scalability (i.e. its distributed shared nothing architecture) will be covered.
Read Getting Started with GEO, CouchDB, and Node.js and learn how open formats like GeoJSON combined with data stores like CouchDB are making development of location based applications easier then ever before. Using NodeJS and CouchDB you can store location data, and perform complex queries on that data quickly.
In CouchDB: The Definitive Guide, three of the core developers gently explain how to work with CouchDB, using clear and practical scenarios. Each chapter showcases key features, such as simple document CRUD (create, read, updated, delete), advanced MapReduce, and deployment tuning for performance and reliability.

About the Author

  A professional writer for over 15 years, Martin ‘MC’ Brown is the author and contributor to over 26 books covering an array of topics, including the recently published Getting Started with CouchDB. His expertise spans myriad development languages and platforms Perl, Python, Java, JavaScript, Basic, Pascal, Modula-2, C, C++, Rebol, Gawk, Shellscript, Windows, Solaris, Linux, BeOS, Microsoft WP, Mac OS and more. He is a former LAMP Technologies Editor for LinuxWorld magazine and is a regular contributor to, LinuxPlanet, ComputerWorld and IBM developerWorks. As a Subject Matter Expert for Microsoft he provided technical input to their Windows Server and certification teams. He draws on a rich and varied background as founder member of a leading UK ISP, systems manager and IT consultant for an advertising agency and Internet solutions group, technical specialist for an intercontinental ISP network, and database designer and programmer and as a self-confessed compulsive consumer of computing hardware and software. MC is currently the VP of Technical Publications and Education for Couchbase and is responsible for all published documentation, training program and content, and the Couchbase Techzone, and can be reached at

Tags: Couchbase Server, JSON, monitor, REST API, statistics,

Comments are closed.