---
id: I0053
title: "Datadog RPC node health checks"
url: https://carbium.sh/library/integrate/datadog-rpc-node-health-checks
collection: Integrations
category: Search and time series
revision: 1
updated: 2026-11-22
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Datadog RPC node health checks

A short probe times six read calls against an RPC node, compares its slot with a reference endpoint, and prints one Datadog series per metric with tags. Monitors and slot thresholds for 200 ms slots come with it.

## What to watch and what it catches

Your dapp backend calls your own node, and that node can answer every call while it sits behind the chain. The checks here run from outside, the way a client sees the node, and each series comes from one JSON-RPC method. A second endpoint you trust, the reference, supplies the tip the node is measured against.

| Series | Method | What it catches |
|---|---|---|
| `solana.rpc.health` | `getHealth` | The node calls itself unhealthy or stops answering. Agave reports ok while within 128 slots of the cluster's latest optimistically confirmed slot by default, so this series alone misses a node that trails. |
| `solana.rpc.slot_lag` | `getSlot` at `processed` on the node and on the reference | A node that answers but trails the tip. The value is reference slot minus node slot. |
| `solana.rpc.block_height` | `getBlockHeight` at `confirmed` | A frozen ledger. The value stops rising while the clock keeps going. |
| `solana.rpc.version` | `getVersion` | A rollout, or a node that came back on an older build. The version sits in a tag and the value is 1. |
| `solana.rpc.latency_ms` | Timing of every call | Slow answers before they turn into errors. One series per method tag. |
| `solana.rpc.slots_per_second` | `getRecentPerformanceSamples` | The pace of the chain itself, about 5 slots a second at 200 ms, so a slow network is not blamed on your node. |
| `solana.rpc.epoch_progress` | `getEpochInfo` | Position in the epoch from 0 to 1. Context for graphs, with nothing to alert on. |

Slot lag is the one that matters most. A node whose replay has stalled still serves its last state to every caller, and the node itself sees nothing wrong until its own distance check trips. Only a second opinion on the tip shows it early.

## The probe function

`probe(node, reference, tags)` takes two clients of the same type, so a client from `createSolanaRpc` with your own node's URL fits as well as the one in the file. It starts seven calls together, each wrapped in `timed`. That wrapper catches its own error and returns a success flag, the value or the message, and the elapsed milliseconds, so one failed call never hides the others. Failed calls print to stderr and the series for the rest still come out.

Commitment is set on each call that takes one. Both slot reads use `processed`, so the lag compares like with like. `getBlockHeight` and `getEpochInfo` use `confirmed`, the level @solana/kit 8.6.0 fills in when a call leaves it out. `getHealth`, `getVersion` and the performance samples take none. Every call has a 5 second abort, and a call past it counts as failed.

The file runs with only a Carbium key, so it passes the Carbium client as both node and reference. The printed lag is then the gap between two reads of one node. In use, build the first client from your node's URL and the second from a different operator, and `probe` is unchanged. Install with `npm install @solana/kit@8.6.0`, set `"type": "module"` in `package.json`, export `CARBIUM_KEY` and run `node main.ts`. Node 24 strips the types on load.

`main.ts` (run: `node main.ts`)

```ts
// I0053 · Datadog RPC node health checks
// https://carbium.sh/library/integrate/datadog-rpc-node-health-checks
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

import { createDefaultRpcTransport, createSolanaRpcFromTransport } from "@solana/kit";

const key = process.env.CARBIUM_KEY;
if (!key) {
  console.error("Set CARBIUM_KEY.");
  process.exit(1);
}
const url = process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh";
const carbium = createSolanaRpcFromTransport(createDefaultRpcTransport({ url, headers: { "x-api-key": key } }));
type Rpc = typeof carbium;
const abortSignal = () => AbortSignal.timeout(5_000); // a call past 5 s counts as failed

type Timed<T> = { ok: true; value: T; ms: number } | { ok: false; error: string; ms: number };
async function timed<T>(call: () => Promise<T>): Promise<Timed<T>> {
  const start = performance.now();
  try {
    return { ok: true, value: await call(), ms: performance.now() - start };
  } catch (e) {
    return { ok: false, error: e instanceof Error ? e.message : String(e), ms: performance.now() - start };
  }
}

// Probe any node client against any reference client; returns Datadog series and the calls that failed.
async function probe(node: Rpc, reference: Rpc, tags: string[]) {
  const [health, slot, height, version, epoch, samples, tip] = await Promise.all([
    timed(() => node.getHealth().send({ abortSignal: abortSignal() })),
    timed(() => node.getSlot({ commitment: "processed" }).send({ abortSignal: abortSignal() })),
    timed(() => node.getBlockHeight({ commitment: "confirmed" }).send({ abortSignal: abortSignal() })),
    timed(() => node.getVersion().send({ abortSignal: abortSignal() })),
    timed(() => node.getEpochInfo({ commitment: "confirmed" }).send({ abortSignal: abortSignal() })),
    timed(() => node.getRecentPerformanceSamples(1).send({ abortSignal: abortSignal() })),
    timed(() => reference.getSlot({ commitment: "processed" }).send({ abortSignal: abortSignal() })),
  ]);
  const timestamp = Math.floor(Date.now() / 1000);
  const series: object[] = [];
  const add = (name: string, value: number, extra: string[] = []) =>
    series.push({ metric: `solana.rpc.${name}`, type: 3, points: [{ timestamp, value }], tags: [...tags, ...extra] });

  const failed: string[] = [];
  const timings = { getHealth: health, getSlot: slot, getBlockHeight: height, getVersion: version, getEpochInfo: epoch, getRecentPerformanceSamples: samples };
  for (const [method, r] of Object.entries(timings)) {
    add("latency_ms", Math.round(r.ms), [`method:${method}`]);
    if (!r.ok) failed.push(`${method}: ${r.error}`);
  }
  if (!tip.ok) failed.push(`reference getSlot: ${tip.error}`);

  add("health", health.ok ? 1 : 0);
  if (slot.ok && tip.ok) add("slot_lag", Number(tip.value - slot.value));
  if (height.ok) add("block_height", Number(height.value));
  if (version.ok) add("version", 1, [`solana_core:${version.value["solana-core"]}`]);
  if (epoch.ok) add("epoch_progress", Number(epoch.value.slotIndex) / Number(epoch.value.slotsInEpoch));
  const sample = samples.ok ? samples.value[0] : undefined;
  if (sample) add("slots_per_second", Number(sample.numSlots) / sample.samplePeriodSecs);
  return { series, failed };
}

// Here the node and the reference are both Carbium; swap in your own node's client as the first argument.
const { series, failed } = await probe(carbium, carbium, [`rpc_node:${new URL(url).host}`, "service:dapp-backend"]);
for (const f of failed) console.error("failed:", f);
console.log(JSON.stringify({ series }, null, 1));
```

A probe sends seven calls. `getHealth`, `getVersion` and `getSlot` are [cached reads at 1 cell each](https://carbium.sh/docs#rpc), and the key goes in the [`x-api-key` header](https://carbium.sh/docs#auth). At a 15 second cadence the probe averages under half a call a second in total. [Limits are per account](https://carbium.sh/docs#limits), so the probe shares its budget with the keys your app uses.

## Datadog series, tags and monitors

The output is the body of Datadog's v2 metrics submission: a `series` array whose items carry `metric`, `type`, `points` and `tags`. Type 3 is a gauge, and a point is a Unix timestamp in seconds with a number. Post the body to `/api/v2/series` on your Datadog site with a `DD-API-KEY` header, or send each value to DogStatsD as a gauge. The file prints the body and sends nothing.

Tags stay few and bounded. `rpc_node` carries the host of the URL, so a second node adds a value and no new metric. `service` names the app that depends on the node. The version rides in `solana_core`, and each method gets its own `method` tag on the latency series. A slot number in a tag would create a new series every probe, so numbers stay in values.

- Health: `max(last_3m):avg:solana.rpc.health{*} by {rpc_node} < 1` goes critical when every point in three minutes is 0. Adjust the tags in each query to your own.
- Slot lag: `avg(last_5m):avg:solana.rpc.slot_lag{*} by {rpc_node} > 10` warns, and the same query at 25 pages.
- Block height: `change(avg(last_5m),last_5m):avg:solana.rpc.block_height{*} by {rpc_node} <= 0` goes critical when the height has not risen over five minutes.
- No data: switch on notify-on-no-data for all three, so a dead probe shows up as an alert.

Send block height as the raw value and let the monitor compute the change. A gauge keeps the query simple, and a probe restart cannot make a counter jump. Version has no threshold. Graph it as a count by `solana_core` and read a change as an event.

## Thresholds in slots

A slot is about 200 ms, so slot counts convert to seconds by dividing by 5. The numbers below are starting values, and a week of your own data will move them.

- 0 to 3 slots (up to 0.6 s): normal. Two reads at `processed` land a few milliseconds apart, and a healthy node differs from the tip by a slot or two.
- 10 slots (2 s) averaged over five minutes: warn. The node is replaying, yet it is late enough that a read after a write can miss it.
- 25 slots (5 s) averaged over five minutes: page. Reads served from this node show state several seconds old.
- 128 slots (about 26 s): the point where the node's own health check turns to an error. A probe that waits for this trips late.

Averaging over five minutes absorbs the single slow probe. If your dapp tolerates less, shorten the window and accept more pages. For block height, 5 slots a second means about 75 slots in a 15 second probe interval, and some slots are skipped, so the height rises a little slower than the slot. Any positive change over five minutes passes the monitor above.

For a pass or fail gate on call latency in a build pipeline, see [RPC latency CI gate](https://carbium.sh/library/blockchainideas/rpc-latency-ci-gate). Here, latency is a graph and a monitor for you to tune.

## Where it ends

- The probe sees the node from one place. It reports the network path from that machine as well as the node, so run it where your backend runs.
- It reads no disk, memory, CPU or validator internals such as vote credits, gossip or ledger size. Those come from the Datadog Agent on the node host.
- A reference that trails hides real lag, and one that shares a failure domain with the node hides it too. Pick a reference with its own operator.
- A probe every 15 seconds sees one moment. A dip that starts and ends between two probes goes unseen.
- It does not run your app's calls. A node can pass every probe and still reject a request your app sends.
- A probe that dies sends no metric, and only the no-data monitor turns that into an alert.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| `solana.rpc.health` stays at 1 while `solana.rpc.slot_lag` climbs past 30. | The node's own check allows 128 slots, about 26 seconds. Alert on slot lag and keep health as the check for a node that stops answering. |
| `solana.rpc.slot_lag` shows small negative values. | The reference read landed a moment after the node read, or the reference trails the node. The lag monitor fires only above 10, so negative values never trigger it. Check the reference when the lag stays negative. |
| Every call prints `failed:` with an HTTP 401, and only the latency series and a `solana.rpc.health` value of 0 come out. | The key is unknown to the door. Attach the whole key in the `x-api-key` header through `CARBIUM_KEY`, with no spaces or quotes inside the value. |
| A probe prints `failed: getSlot` with an HTTP 429 and the lag series has gaps. | The account's budget is spent, usually by app traffic on other keys. Lengthen the probe interval or lower that traffic, and read the retry-after hint on the 429 for the wait. |
| The block height monitor fires right after a probe restart or a first deploy. | A change monitor compares two windows, and the earlier one holds no points. Mute it for the first ten minutes, or start the probe before the monitor. |
| The version series splits into two lines during a rollout and a dashboard reads it as an error. | Each version is its own tag value, so two lines are expected while hosts differ. Graph version as a count by `solana_core` and treat the second line as an event marker. |

## Questions

### Why not alert on `getHealth` alone?

It answers ok within 128 slots of the cluster's latest optimistically confirmed slot by default, which is about 26 seconds at 200 ms slots. A node can trail for that long before it fails.

### Can the reference be the same provider as the node?

In the file it is, so one key runs the whole probe. For alerts, use a reference run by someone else, because two endpoints behind one failure share it and report a lag of zero together.

### How often should the probe run?

Every 15 seconds is a fair start. It sees about 75 slots between probes, and the seven calls a probe sends stay well inside the account's rate. Run it faster only when a monitor window of a minute needs more points.

### Why is version a gauge with a tag and not a number?

A gauge carries a number, and a version string is text. The value is always 1 and the string rides in `solana_core`, so Datadog can count nodes by version.

## Related

- [RPC latency CI gate](https://carbium.sh/library/blockchainideas/rpc-latency-ci-gate) (Blockchain ideas, BI0032)
- [RPC rate-limit alerts](https://carbium.sh/library/usecase/rpc-rate-limit-alerts) (Use cases, UC0001)
- [carbium.sh/docs#rpc](https://carbium.sh/docs#rpc)
- [carbium.sh/docs#endpoints](https://carbium.sh/docs#endpoints)
- [carbium.sh/docs#auth](https://carbium.sh/docs#auth)
- [carbium.sh/docs#limits](https://carbium.sh/docs#limits)
