Fetch health condition (enhancement)

Moved from GitHub dgraph-js/27

Posted by MichelDiz:

Is it possible to add a fetch to the health condition of the instance?

I would like to make routine checks within my application.
Without having to turn to Prometheus / Grafana.

In my case, the Dgraph Server instance and Zero are behind an API. I do not expose them. I’ve tried using isomorphic-fetch but the result format is not compatible. And as I’m using Rancher, it gets tricky to keep exact internal domainname.

fetch('http://192.168.1.200:8089/health')
  .then(function(response) {
    if (response.status >= 400) {
      throw new Error('Bad response from server');
    }
    return response.json();
  })
  .then(function(response) {
    console.log(response.json());
  });

It would be possible?

Thanks.

Cheers.

manishrjain commented :

If an external Dgraph client can talk to these servers, then you could potentially use some HTTP client to query for health.

MichelDiz commented :

Actually instances with the Dgraph stack are behind a Reverse Proxy. I did not want to open a public endpoint for it. An internal kind of “ping” from the client would help in this case.

But in the impossibility, no problem. It’s just a case.

gpahal commented :

But the client also requires you to open a public grpc port. Is the client also behind the proxy?

MichelDiz commented :

I’m not using gRPC in my own user client. I’m query through a Graphql gateway. So That way I can take advantage of an Apollo (apollographql).

PS. We can see /health through grpc??

MichelDiz commented :

Another point is that I’m using Rancher. Often times when upgrade the instances to a more current version or even restart the service or any other task. The IPs change, although Rancher has an internal DNS sometimes inconsistent.

manishrjain commented :

This seems a bit specific use case to be added for general usage. @MichelDiz , I’m sure you can find a way around this, and use the HTTP based health checker.

MichelDiz commented :

I’ll try this dgraph/connection.js at 0cbe6030569452f29dbaab6e37a2311b4800b71c · dgraph-io/dgraph · GitHub But I will have to deal with the internal domain thing.