// CheckHealth handles health checks sent from Grafana to the plugin.
// The main use case for these health checks is the test button on the
// datasource configuration page which allows users to verify that
// a datasource is working as expected.
CheckHealth handles health checks sent from Grafana to the plugin.
The main use case for these health checks is the test button on the
datasource configuration page which allows users to verify that
a datasource is working as expected.
// CheckHealth handles health checks sent from Grafana to the plugin . // The main use case for these health checks is the test button on the // datasource configuration page which allows users to verify that // a datasource is working as expected .
func (d *CouchbaseDatasource) CheckHealth(_ context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error) {
  if pings, be := d.Cluster.Ping(&gocb.PingOptions{
      ReportID: "grafana-test",
      ServiceTypes: []gocb.ServiceType{gocb.ServiceTypeQuery},
    }); be != nil {
      log.DefaultLogger.Error("Failed to ping the cluster", "error", be.Error())
      return &backend.CheckHealthResult{
        Status: backend.HealthStatusError,
        Message: be.Error(),
      }, be
    } else {
     for _, responses := range pings.Services{
       for _, response := range responses {
         if response.State != gocb.PingStateOk {
           return &backend.CheckHealthResult{
             Status: backend.HealthStatusError,
             Message: fmt.Sprintf("Node %s at remote %s ping response was not ok: %s", response.ID, response.Remote, response.Error),
           }, nil
         }
       }
     }
    }
    log.DefaultLogger.Info("Verified cluster connectivity")
    return &backend.CheckHealthResult{
      Status: backend.HealthStatusOk,
      Message: "Ping OK",
    }, nil
  }
func ( d * CouchbaseDatasource ) CheckHealth ( _ context . Context , req * backend . CheckHealthRequest ) ( * backend . CheckHealthResult , error ) { if pings , be := d . Cluster . Ping ( & gocb . PingOptions { ReportID : " " , ServiceTypes : [ ] gocb . ServiceType { gocb . ServiceTypeQuery } , } ) ; be != nil { log . DefaultLogger . Error ( " " , " " , be . Error ( ) ) return & backend . CheckHealthResult { Status : backend . HealthStatusError , Message : be . Error ( ) , } , be } else { for _ , responses := range pings . Services { for _ , response := range responses { if response . State != gocb . PingStateOk { return & backend . CheckHealthResult { Status : backend . HealthStatusError , Message : fmt . Sprintf ( " " , response . ID , response . Remote , response . Error ) , } , nil } } } } log . DefaultLogger . Info ( " " ) return & backend . CheckHealthResult { Status : backend . HealthStatusOk , Message : " " , } , nil }
CheckHealth handles health checks sent from Grafana to the plugin.
CheckHealth handles health checks sent from Grafana to the plugin .