---
id: I0131
title: "Kibana TPS chart"
url: https://carbium.sh/library/integrate/kibana-tps-chart
collection: Integrations
category: Search and time series
revision: 1
updated: 2026-11-23
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Kibana TPS chart

A small Node script reads the newest transaction-count samples from your Carbium RPC, works out transactions per second for each, and writes them to an Elasticsearch index that a Kibana line chart reads.

## What the job reads and writes

The job makes one call per run, `getRecentPerformanceSamples`, on your [Carbium RPC endpoint](https://carbium.sh/docs/endpoints). The call returns the newest samples the node holds. Each sample carries the slot it reports, the number of transactions counted in its period and the period length in seconds. Dividing the first by the second gives transactions per second for that period.

The script writes one bulk body for Elasticsearch, with one document per sample, into an index called `solana-tps`. The document id is the slot, so a later run that reads an overlapping window overwrites the same documents instead of adding copies. Kibana then charts the `tps` field against `@timestamp` as a line.

The job is read-only. It sends no transactions, holds no signing key and writes only to Elasticsearch or to a local file.

## What a sample counts

The method takes a count from 1 to 720, and the script defaults to 30. It takes no commitment argument, so nothing in the request picks a commitment level for the samples.

Each sample's `numTransactions` is the count for its period, and `samplePeriodSecs` is the period length. The script divides one by the other and keeps the result as a float, so a quiet period charts as a low value instead of a gap.

The count comes from the samples, so the job does not read block contents at all. If you later count transactions from `getBlock` instead, note that mainnet blocks carry no vote transactions since the Alpenglow switch, so that count needs no vote filter.

## The Kibana side: index and chart

The first bulk write creates the index with dynamic mapping, which reads the ISO timestamp as a date. The fields the script sends are below, so you can set the types yourself before the first run if you prefer explicit mapping.

| Field | Type in the index | Holds |
|---|---|---|
| @timestamp | date | the time the run read the samples |
| slot | keyword | the slot the node reports for the sample, also the document id |
| tps | float | transactions divided by the period length |
| transactions | long | the sample's count as the node reports it |
| period_secs | integer | the sample's period length in seconds |

In Kibana, open the data views page and create a view on `solana-tps` with `@timestamp` as its time field. Then build a line chart in Lens with `@timestamp` on the horizontal axis and the average of `tps` on the vertical axis. Each document is one sample, so the average needs no extra aggregation to show the rate.

`ELASTIC_URL` and `ELASTIC_API_KEY` are optional. Without them the script writes `tps.ndjson` and stops, which is enough to check the output before a cluster is wired. With them, the key goes in the `Authorization` header as `ApiKey`, and the script never prints it.

## Run it on a schedule

Run `node main.ts 30` every minute from cron or a systemd timer. Each run makes one RPC call, so the load is one request a minute. [Limits are per account](https://carbium.sh/docs/limits), so every other job on the same key draws on the same budget.

A call over its rate waits once and is served if its cells refill within a second. Past that, Carbium answers 429 with a retry-after hint, and the script prints the hint and exits without writing. The next scheduled run reads a fresh window, and the overlap between runs keeps a skipped minute from leaving a hole the size of the window.

## Where it ends

- It charts the count the node reports for each sample. It does not check that count against blocks you fetched.
- Samples carry no time, so every document from one run shares the run's timestamp. Points are placed by run, not by the moment each sample ended.
- A gap longer than the window, which is the count times the period, leaves a hole in the chart. The script does not fill it.
- The script reads only the newest samples. History is whatever the index holds from earlier runs, so a day of chart needs a day of scheduled runs.
- Nothing here alerts. A threshold alert on `tps` is a separate Kibana rule that you set up in Kibana.

## The script

Install nothing beyond `@solana/kit`, which is pinned at 8.6.0, and set `"type": "module"` in `package.json`. Node 24 strips the types on load. The script reads `CARBIUM_KEY` and exits with a message if it is unset.

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

```ts
// I0131 · Kibana TPS chart
// https://carbium.sh/library/integrate/kibana-tps-chart
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

import {
  createDefaultRpcTransport,
  createSolanaRpcFromTransport,
  isSolanaError,
  SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR,
} from "@solana/kit";
import { writeFile } from "node:fs/promises";

const key = process.env.CARBIUM_KEY;
if (!key) {
  console.error("Set CARBIUM_KEY to your Carbium key and run again.");
  process.exit(1);
}
const count = Number(process.argv[2] ?? 30);
if (!Number.isInteger(count) || count < 1 || count > 720) {
  console.error("The sample count must be a whole number from 1 to 720.");
  process.exit(1);
}

const rpc = createSolanaRpcFromTransport(
  createDefaultRpcTransport({
    url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh",
    headers: { "x-api-key": key },
  }),
);

try {
  const samples = await rpc
    .getRecentPerformanceSamples(count)
    .send({ abortSignal: AbortSignal.timeout(10_000) });
  const at = new Date().toISOString();
  const rows = samples.map((s) => {
    const period = Math.max(1, s.samplePeriodSecs);
    const transactions = Number(s.numTransactions);
    return { slot: String(s.slot), tps: transactions / period, transactions, period };
  });
  const lines = rows.flatMap((r) => [
    JSON.stringify({ index: { _index: "solana-tps", _id: r.slot } }),
    JSON.stringify({ "@timestamp": at, slot: r.slot, tps: r.tps, transactions: r.transactions, period_secs: r.period }),
  ]);
  const body = lines.join("\n") + "\n";
  await writeFile("tps.ndjson", body);
  const mean = rows.reduce((sum, r) => sum + r.tps, 0) / rows.length;
  console.log(`samples ${rows.length}, newest slot ${rows[0]?.slot}, newest tps ${rows[0]?.tps.toFixed(1)}, mean tps ${mean.toFixed(1)}`);
  console.log("wrote tps.ndjson, a bulk body for index solana-tps");

  const esUrl = process.env.ELASTIC_URL;
  const esKey = process.env.ELASTIC_API_KEY;
  if (esUrl && esKey) {
    const res = await fetch(`${esUrl}/_bulk`, {
      method: "POST",
      headers: { "content-type": "application/x-ndjson", authorization: `ApiKey ${esKey}` },
      body,
      signal: AbortSignal.timeout(15_000),
    });
    const out = (await res.json()) as { errors?: boolean };
    console.log(res.ok ? `Elasticsearch accepted ${rows.length} samples${out.errors ? ", some rows rejected" : ""}` : `Elasticsearch answered ${res.status}`);
  }
} catch (e) {
  if (isSolanaError(e, SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR)) {
    console.error(`Carbium answered HTTP ${e.context.statusCode}; on 429, wait for the retry-after hint and run again.`);
  } else {
    console.error("TPS read failed:", e instanceof Error ? e.message : String(e));
  }
  process.exit(1);
}
```

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| The run prints `Carbium answered HTTP 401` and exits. | The key is missing or wrong. An unknown key gets 401 at the door, so check that `CARBIUM_KEY` holds the whole key and that it goes in the [x-api-key header](https://carbium.sh/docs/auth). The [errors page](https://carbium.sh/docs/errors) lists the other codes. |
| The run prints `Carbium answered HTTP 429` and writes no file. | The key's budget is spent, usually by other jobs on the same key. Wait for the retry-after hint, then run again, and move this schedule away from the other jobs. |
| Every point from one run sits at the same instant in the chart. | That is the design. Samples carry no time, so the run's timestamp stands for all of them. Read the chart at the run's resolution, one point per run and minute. |
| Elasticsearch answers with an error status, or the response names rejected rows. | Check that the API key can write to `solana-tps` and that the body ends with a newline, which the script adds. A rejected row means one document failed on its own, and the others were written. |
| The script exits with a message about the sample count before any call is made. | Pass a whole number from 1 to 720 as the first argument. The script refuses anything else before it calls Carbium. |

## Questions

### Is this the same as counting transactions on the chain myself?

Not quite. The script charts the node's own count for each sample period, so it reads a counter the node keeps. Summing the transactions of blocks you fetched gives a count you can check transaction by transaction, at the cost of many more calls.

### Why is the document id the slot?

Overlapping runs read the same samples, and a slot identifies one sample. A repeated read overwrites that document, so the chart does not double its points.

### Does the Carbium key reach Elasticsearch?

No. The Carbium key goes only to Carbium in the `x-api-key` header, and the Elastic key goes only to the Elasticsearch URL in the `Authorization` header.

### Can the chart show a past day?

Only as far back as the index holds. The script writes what each run sees, so a past day needs a day of scheduled runs before it appears.

## Related

- [Non-vote TPS meter](https://carbium.sh/library/blockchainideas/non-vote-tps-meter) (Blockchain ideas, BI0063)
- [Token supply time series](https://carbium.sh/library/integrate/token-supply-time-series) (Integrations, I0006)
- [carbium.sh/docs/endpoints](https://carbium.sh/docs/endpoints)
- [carbium.sh/docs/auth](https://carbium.sh/docs/auth)
- [carbium.sh/docs/rpc](https://carbium.sh/docs/rpc)
- [carbium.sh/docs/limits](https://carbium.sh/docs/limits)
- [carbium.sh/docs/errors](https://carbium.sh/docs/errors)
