Health check using gRPC client

Hi,

I am trying to establish Dgraph connection using gRPC client, even though the Port is wrong its not throwing an error

How to check the connection whether the connection is established sucessfully and how to do health checks for the connection

Point me to the documentation if any

Thank you

func newClient() *dgo.Dgraph {
	// Dial a gRPC connection. The address to dial to can be configured when
	// setting up the dgraph cluster.
	d, err := grpc.Dial("localhost:9080", grpc.WithInsecure())
	if err != nil {
		log.Fatal(err)
	}
	return dgo.NewDgraphClient(
		api.NewDgraphClient(d),
	)
}

@teja

It does not throw an error at the time of the creation of the client. It just initializes the structures. However, if you try to connect to the alpha for query, mutation etc., it throws an error. (try altering the schema https://dgraph.io/docs/clients/#alter-the-database)That’s when the client contacts the alpha.

If you want to do health check connection establishment via client then sending a low payload request could be one simple way. Logs at server might be another useful way. Maybe @dmai, @MichelDiz can point you with some other methods. You can look at https://godoc.org/github.com/dgraph-io/dgo for other available APIs of Dgraph go-client.

2 Likes

I think that no client can do this. I have been there heheheh → Fetch health condition (enhancement) · Issue #27 · dgraph-io/dgraph-js · GitHub

But, you can check this using admin GraphQL query. You can use a small GraphQL client to “ping” this.

Instance: String
Node type : either ‘alpha’ or ‘zero’.

address: String
Address of the node.

status: [String
Node health status : either ‘healthy’ or ‘unhealthy’.

group: [String
The group this node belongs to in the Dgraph cluster. See : Self-managed cluster - Deploy.

version: String
Version of the Dgraph binary.

uptime: Int
Time in nanoseconds since the node started.

lastEcho: Int
Time in Unix epoch time that the node was last contacted by another Zero or Alpha node.

ongoing: [String]
List of ongoing operations in the background.

indexing: [String]
List of predicates for which indexes are built in the background.

ee_features: [String]
List of Enterprise Features that are enabled.

1 Like