{{announcement.body}}
{{announcement.title}}

Monitoring Apache Zookeeper Servers

DZone 's Guide to

Monitoring Apache Zookeeper Servers

This article shows you how to monitor Apache Zookeeper servers using Netflix Exhibitor.

· Big Data Zone ·
Free Resource

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.

Java
 


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:

  • Status

The best way to monitor the status of the entire cluster is to use the cluster status Rest API from exhibitor.

Method GET
URL exhibitor/v1/cluster/status
Argument n/a
Response ServerStatus[]


Java
 


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.

Code State
0 LATENT
1 DOWN
2 NOT_SERVING
3 SERVING


The isLeader boolean field helps you determine the current leader of the cluster.

  • RemoteGetStatus

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.

Method GET
URL exhibitor/v1/cluster/state/{hostname}
Argument N/A
Response ClusterState
Java
 


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.

ClusterSwitches

Java


  • getStatus

The getStatus API returns the state of the local zookeeper instance.

Method GET
URL exhibitor/v1/cluster/state
Argument N/A
Response ClusterState


Java


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

Topics:
apache zookeeper ,big data ,netflix exhibitor ,tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}