Monitoring Apache Zookeeper Servers
This article shows you how to monitor Apache Zookeeper servers using Netflix Exhibitor.
Join the DZone community and get the full member experience.Join For Free
Apache zookeeper is the go-to service for maintaining and managing data in a distributed environment. It is highly popular coordination and synchronization service for storing and maintaining data for distributed systems. Various systems are using Apache Zookeeper servers for leader election, registry naming, node coordination, and data management. It is widely used in the industry for Apache Hadoop, Apache HBase, Apache Kafka, etc. Zookeeper makes it quite easy to implement advanced patterns in distributed systems.
Management of data is a complicated task in a distributed system. Apache zookeeper does a good job of coordination across multiple nodes so that application developers do not need to worry about such common problems in distributed systems. It is simple and easy to use, and it is itself distributed over multiple nodes so that there is no single point of failure.
Many times in distributed systems, there is a need to monitor zookeeper servers. The common way of doing this is to use the four-letter “srvr” command.
However, this command needs to be run on all the nodes to check their status.
Exhibitor provided by Netflix is a supervisor system for Apache Zookeeper. Exhibitor comes with a built-in Rest API that provides more information on the Zookeeper ensemble instances.
The Exhibitor Rest APIs are grouped in various categories. To monitor the entire zookeeper cluster, you should look into the cluster category.
Some of the useful APIs for monitoring zookeeper servers is as follows:
The best way to monitor the status of the entire cluster is to use the cluster status Rest API from exhibitor.
Exhibitor internally makes Rest calls to each of the other servers in the ensemble and provides an integrated view of the cluster. This is very useful to obtain the complete cluster status by invoking the Rest API on a single node. The code integer specified in the Rest API response above is the state of the Zookeeper server. For eg, in the above call, the code 3 denotes that the server has status as serving.
The isLeader boolean field helps you determine the current leader of the cluster.
There is a remoteGetStatus API that returns the status of the provided instance. This can be used to check the status of local as well as remote servers.
In the API response of the remoteGetStatus API, the state, description, and isLeader information is the same as the cluster status API. There is additional information on switches that are provided here.
The getStatus API returns the state of the local zookeeper instance.
The API response of getStatus has the same parameters as the remoteGetStatus. You can refer to the Exhibitor Rest Entities page for more details.
Using the Rest APIs of Exhibitor is an excellent way to obtain the status of the entire cluster. The. Exhibitor Rest APIs can be easily incorporated into application workflows to get information about the cluster
Opinions expressed by DZone contributors are their own.