Health Check

  • concept
Health Check provides ping() and diagnostics() tests for the health of the network and the cluster.

Unresolved include directive in modules/concept-docs/pages/health-check.adoc - include::3.10@sdk:pages:partial$health-check.adoc[]

Unresolved include directive in modules/concept-docs/pages/health-check.adoc - include::3.10@sdk:pages:partial$health-check.adoc[]

Unresolved include directive in modules/concept-docs/pages/health-check.adoc - include::3.10@sdk:pages:partial$health-check.adoc[]

A ping can be performed either at the Cluster or at the Bucket level. They are very similar, although at the Bucket level also the Key/Value and View connections for the specific bucket are taken into account.

The report can either be analyzed in code or can be turned into JSON and printed:

IPingReport report = await bucket.PingAsync(options =>
{
    options.ServiceTypes(new ServiceType[] {ServiceType.KeyValue, ServiceType.Query});
});

Console.WriteLine(report);

// alternatively, format the output with indenting:
//Console.WriteLine(JsonConvert.SerializeObject(report, Formatting.Indented));

You will see an output similar to this:

{
  "id": "174ad024-43d4-410c-9d80-61788b4f3bf4",
  "version": 1,
  "config_rev": 572,
  "sdk": "couchbase-net-sdk/3.0.7.0 (clr/.NET Core 3.1.9) (os/Microsoft Windows 10.0.18363)",
  "services": {
    "n1ql": [
      {
        "state": "ok",
        "remote": "[::1]:11210",
        "last_activity_us": 0,
        "latency_us": 135751,
        "scope": "Cluster"
      }
    ],
    "kv": [
      {
        "id": "2",
        "state": "ok",
        "local": "[::1]:53183",
        "remote": "[::1]:11210",
        "last_activity_us": 81526,
        "latency_us": 2330,
        "scope": "travel-sample"
      },
      {
        "id": "1",
        "state": "ok",
        "local": "[::1]:53184",
        "remote": "[::1]:11210",
        "last_activity_us": 94655,
        "latency_us": 312,
        "scope": "travel-sample"
      }
    ]
  }
}

Notice the scope of each service. Bucket level services like key/value will have a bucket name as scope, while cluster level services will have "Cluster" as their scope.

Unresolved include directive in modules/concept-docs/pages/health-check.adoc - include::3.10@sdk:pages:partial$health-check.adoc[]

IDiagnosticsReport diagnosticsReport = await cluster.DiagnosticsAsync();

Console.WriteLine(diagnosticsReport);

// alternatively, format the output with indenting:
// Console.WriteLine(JsonConvert.SerializeObject(diagnosticsReport, Formatting.Indented));

You will see an output similar to this:

{
  "id": "b084360a-82b1-4602-b983-281d3cc11b3b",
  "version": 1,
  "sdk": "couchbase-net-sdk/3.0.7.0 (clr/.NET Core 3.1.9) (os/Microsoft Windows 10.0.18363)",
  "services": {
    "kv": [
      {
        "id": "2",
        "state": "authenticating",
        "local": "[::1]:53491",
        "remote": "[::1]:11210",
        "last_activity_us": 61153,
        "scope": "travel-sample"
      },
      {
        "id": "1",
        "state": "authenticating",
        "local": "[::1]:53492",
        "remote": "[::1]:11210",
        "last_activity_us": 66101,
        "scope": "travel-sample"
      }
    ],
    "view": [
      {
        "state": "new",
        "remote": "[::1]:11210",
        "last_activity_us": 0,
        "scope": "travel-sample"
      }
    ],
    "n1ql": [
      {
        "state": "new",
        "remote": "[::1]:11210",
        "last_activity_us": 0,
        "scope": "Cluster"
      }
    ],
    "cbas": [
      {
        "state": "new",
        "remote": "[::1]:11210",
        "last_activity_us": 0,
        "scope": "Cluster"
      }
    ],
    "fts": [
      {
        "state": "new",
        "remote": "[::1]:11210",
        "last_activity_us": 0,
        "scope": "Cluster"
      }
    ]
  }
}

Like with Ping, notice the scope of each service.