Skip to main content

Health

c.Health calls the API's Health group. Health check endpoints for liveness, readiness, and detailed status.

Methods​

MethodReturnsPermissionDescription
Liveness(ctx)*Response[HealthResponse]Liveness probe.
Ready(ctx)*Response[ReadyResponse]Readiness probe.
Status(ctx, params)*Response[StatusResponse]health:readSystem status and component health.

Liveness​

func (s *HealthService) Liveness(
ctx context.Context,
) (*Response[HealthResponse], error)

Liveness probe.

Returns 200 if the process is alive. No checks performed.

It sends GET /api/health, and needs no permission.

The examples of the method's definition:

Liveness probe, go run health.go liveness:

resp, err := c.Health.Liveness(ctx)

Ready​

func (s *HealthService) Ready(
ctx context.Context,
) (*Response[ReadyResponse], error)

Readiness probe.

Returns 200 when the service is ready to accept traffic.

It sends GET /api/health/ready, and needs no permission.

The examples of the method's definition:

Readiness probe, go run health.go ready:

resp, err := c.Health.Ready(ctx)

Status​

func (s *HealthService) Status(
ctx context.Context,
params HealthStatusParams,
) (*Response[StatusResponse], error)

System status and component health.

Returns per-component health status with system metrics. Requires authentication.

It sends GET /api/health/status, and needs the permission health:read.

The examples of the method's definition:

System status and component health, go run health.go status:

resp, err := c.Health.Status(ctx, client.HealthStatusParams{})

System status and component health, with --component agent, go run health.go status-2:

resp, err := c.Health.Status(ctx, client.HealthStatusParams{Component: types.ComponentType("agent")})

Types​

The fields of each type are the properties of its schema in the API's spec.

AgentDetail​

FieldTypeDescription
HostnamestringAgent hostname.
LabelsstringFormatted label string.
RegisteredstringTime since last heartbeat registration.

AgentStats​

FieldTypeDescription
Agents[]AgentDetailPer-agent registration details.
ReadyintNumber of agents with Ready status.
TotalintTotal number of registered agents.

Check​

FieldTypeDescription
ErrorstringWhy the check failed. Absent when it is ok.
NamestringWhat was checked, such as nats.
Statusstringok, or error.

ComponentEntry​

FieldTypeDescription
AddressstringListen address of a sub-component, such as :8080.
AgestringTime since component started.
Components[]ComponentEntryThe sub-components of the component, such as its api and its metrics server, sorted by name.
Conditions[]ConditionTypeActive conditions.
CPUPercentfloat64Process CPU usage percentage.
HostnamestringComponent hostname.
MemBytesint64Process RSS memory in bytes.
StatusstringComponent status.
TypestringComponent type (agent, controller, nats), or the name of a sub-component, such as api.
URLstringWhere a person opens a sub-component, from its url config key.
VersionstringBuild version of the component's binary.

ComponentType​

ComponentType is the type of a part of osapi that reports its health.

A string, one of controller, nats, agent.

ConditionType​

A condition that an agent or a component evaluates.

A string, one of MemoryPressure, HighLoad, DiskPressure, DrainStuck, ConsumersUnavailable, ProcessMemoryPressure, ProcessHighCPU.

HealthResponse​

FieldTypeDescription
StatusstringHealth status.

JobStats​

FieldTypeDescription
CompletedintNumber of completed jobs.
DLQintNumber of jobs in the dead letter queue.
FailedintNumber of failed jobs.
ProcessingintNumber of jobs currently processing.
SubmittedintNumber of jobs that no agent has taken.
TotalintTotal number of jobs.

KVBucketInfo​

FieldTypeDescription
BytesintTotal bytes in the bucket.
KeysintNumber of keys in the bucket.
NamestringKV bucket name.

NATSInfo​

FieldTypeDescription
URLstringConnected NATS server URL.
VersionstringNATS server version.

ObjectStoreInfo​

FieldTypeDescription
NamestringObject Store bucket name.
SizeintTotal bytes in the store.

ReadyResponse​

FieldTypeDescription
ErrorstringError message when not ready.
StatusstringReadiness status.

StatusResponse​

FieldTypeDescription
AgentsAgentStats
Checks[]CheckWhat the controller that answered checked for this answer: its connection to NATS and to the KV store.
ConsumersintTotal number of JetStream consumers: the sum of the consumers of each stream.
JobsJobStats
KVBuckets[]KVBucketInfoKV bucket statistics.
NATSNATSInfo
ObjectStores[]ObjectStoreInfoObject Store statistics.
Registry[]ComponentEntryAll registered components with health details, each with its sub-components.
StatusstringOverall health status.
Streams[]StreamInfoJetStream stream statistics.
UptimestringTime since server started.
VersionstringApplication version.

StreamInfo​

FieldTypeDescription
BytesintTotal bytes in the stream.
ConsumersintNumber of consumers on the stream.
MessagesintNumber of messages in the stream.
NamestringStream name.

Example​

examples/sdk/client/health.go runs each example of this page. With no argument, it lists them.