A Weaviate node refers to an individual instance or installation of the Weaviate database. It represents a single unit within a distributed network that stores and processes the data using the Weaviate architecture.
Each node in Weaviate can function independently or collaborate with other nodes to form a decentralized network for data storage, retrieval, and search operations.
Sometimes, you may need to gather information about a given node. In this tutorial, we will explore the various methods to get the details about a given Weaviate node.
Requirements:
To follow along with this post, you need the following:
- An HTTP client such as cURL
- Python 3.10 and above
- A running Weaviate instance
- Weaviate Python Client
Get the Node Info in Weaviate Using the HTTP Endpoint
The first method that we can use to get the information about a Weaviate node is the /v1/nodes HTTP endpoint.
We can make a GET request as follows:
The query should return an information about the nodes as follows:
- Name – Name of the node
- Status – Status of the node (one of: HEALTHY, UNHEALTHY, UNAVAILABLE)
- Version – Version of Weaviate that runs on the node
- gitHash – Short git hash of the latest commit of Weaviate that runs on the node
- Stats – Statistics of the node with following fields:
- shardCount – Total number of shards on the node
- objectCount – Total number of objects on the node
- Shards – Array of shards with following fields:
- Name – Name of the shard
- Class – Name of the objects’ class stored on the shard
- objectCount – Number of objects on the shard
The following command shows how to use cURL to request the node’s endpoint:
Ensure to replace the URL with your target Weaviate instance address.
This should return an information about the Weaviate node as follows:
Get the Node Info in Weaviate Using Python
The second and most programmatic method of fetching the information about the nodes in Weaviate is using the Python client.
Once you have the Weaviate client installed, create the client and use the code as follows:
client = weaviate.Client("http://localhost:8080")
nodes_status = client.cluster.get_nodes_status()
print(nodes_status)
An example output is as follows:
There you have it!
Conclusion
We explored how to show the node information in Weaviate using the HTTP endpoints and a Python client.