DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Getting Started With the YugabyteDB Managed REST API
  • Auditing Tools for Kubernetes
  • Kubernetes Cluster Setup on Ubuntu, Explained
  • Upgrading Kubernetes Clusters With Cluster API on Oracle Cloud

Trending

  • Top Book Picks for Site Reliability Engineers
  • Integrating Security as Code: A Necessity for DevSecOps
  • Medallion Architecture: Why You Need It and How To Implement It With ClickHouse
  • Building Scalable and Resilient Data Pipelines With Apache Airflow
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Monitoring Apache Zookeeper Servers

Monitoring Apache Zookeeper Servers

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

By 
Shweta Behere user avatar
Shweta Behere
·
Updated May. 21, 20 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
9.0K Views

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.

Java
 
xxxxxxxxxx
1
10
 
1
root@host:~# echo srvr | nc localhost 2181
2
Zookeeper version: 3.4.12-9a32a0b3d8a6492fa18ed92f6d2408bbfc408912, built on 07/01/2019 19:04 GMT
3
Latency min/avg/max: 0/0/41
4
Received: 6165
5
Sent: 6326
6
Connections: 22
7
Outstanding: 0
8
Zxid: 0x2d55000000d2
9
Mode: follower
10
Node count: 2923


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
 
xxxxxxxxxx
1
 
1
root@host:~# curl http://10.65.115.67:8180/exhibitor/v1/cluster/status
2
[{"code":3,"description":"serving","hostname":"10.120.187.29","isLeader":false},
3
{"code":3,"description":"serving","hostname":"10.65.115.70","isLeader":false},
4
{"code":3,"description":"serving","hostname":"10.65.115.69","isLeader":false},
5
{"code":3,"description":"serving","hostname":"10.65.115.68","isLeader":false},
6
{"code":3,"description":"serving","hostname":"10.65.115.67","isLeader":true}]


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
 
xxxxxxxxxx
1
 
1
root@host:~# curl http://10.65.115.67:8180/exhibitor/v1/cluster/state/10.65.115.68
2
{"response":{"switches:{"restarts":true,"cleanup":true,"backups":true},"state":3,"description":"serving","isLeader":false},"errorMessage":"","success":true}


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
xxxxxxxxxx
1
 
1
{
2
"restarts": boolean, // true if instance restarts are on
3
"unlistedRestarts": boolean, // true if unlisted instance restarts are on
4
"cleanup": boolean, // true if the cleanup task is on
5
"backups": boolean // true if the backup task is on
6
}


  • 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
x
 
1
root@host:~# curl http://10.65.115.67:8180/exhibitor/v1/cluster/state
2
{"switches":{"restarts":true,"cleanup":true,"backups":true},"state":3,"description":"serving","isLeader":true}


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

Apache ZooKeeper cluster API

Opinions expressed by DZone contributors are their own.

Related

  • Getting Started With the YugabyteDB Managed REST API
  • Auditing Tools for Kubernetes
  • Kubernetes Cluster Setup on Ubuntu, Explained
  • Upgrading Kubernetes Clusters With Cluster API on Oracle Cloud

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!