Skip to content

Latest commit

History

28 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

node-metrics

A small collector + TUI pair for watching Prometheus host metrics as a live terminal graph, over NATS JetStream.

Prometheus --poll--> collector --publish--> NATS JetStream <--read-only-- tui
  • collector polls a Prometheus instance for each host in a scrape job, and publishes readings to a JetStream stream (history) and a KV bucket (latest value + host directory + live republish).
  • tui never talks to Prometheus. It lists currently-reporting hosts from the KV, backfills a window of history from the stream, then switches to a live subscription. Hosts and metrics can be switched at runtime.

Adding a host requires no code change, just a Prometheus scrape config change. Adding a metric is one new entry in internal/registry.

Install

go install github.com/jw4/node-metrics/cmd/collector@latest
go install github.com/jw4/node-metrics/cmd/tui@latest

Or run the collector as a container: ghcr.io/jw4/node-metrics-collector.

Collector

Configured entirely by environment variables:

VariableDefault
NODE_METRICS_PROM_URLhttp://kube-prometheus-stack-prometheus.monitoring.svc.cluster.local:9090
NODE_METRICS_NATS_URLnats://nats.nats-prime.svc.cluster.local:4222
NODE_METRICS_NATS_CREDS(required) path to a .creds file
NODE_METRICS_NATS_TLS_CA(optional) path to a root CA cert
NODE_METRICS_JOBnode-exporter-external
NODE_METRICS_INTERVAL60s
NODE_METRICS_MAX_AGE168h (7d), JetStream stream retention
NODE_METRICS_MAX_BYTES512MiB, JetStream stream size limit
NODE_METRICS_KV_TTL5m
NODE_METRICS_HEALTHZ_ADDR:8080, serves /healthz and /readyz

TUI

go install's binary is named tui (Go names it after the package directory, not the module):

tui -creds tui.creds -nats-url tls://nats.example.com:4222 -tls-ca ca.crt
FlagDefaultMeaning
-nats-urlnats://localhost:4222NATS endpoint
-creds(required)path to a .creds file
-tls-ca(empty)root CA cert; required unless connecting in-cluster
-metriccpu_tempmetric to display
-window1hbackfill window on start / host switch
-log-file(empty)log connection/backfill errors here (bubbletea owns stderr)

Keys: tab/arrows switch hosts.

Requirements

A NATS server with JetStream enabled, and a stream + KV bucket the collector creates on first run. Both binaries connect with NKey/JWT credentials (.creds), set up an account and users however you manage NATS auth.

License

MIT, see LICENSE.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages