metrics

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2026 License: MIT Imports: 9 Imported by: 0

README

Hanzo Metrics

High-performance time-series metrics database.

Overview

Hanzo Metrics is a fast, cost-effective time-series database optimized for monitoring AI infrastructure. Store billions of data points with excellent compression and query performance for your observability needs.

Features

  • High Performance: Fast ingestion and queries
  • Efficient Storage: 10x compression vs alternatives
  • PromQL Compatible: Use familiar Prometheus queries
  • Long-term Storage: Cost-effective retention
  • High Availability: Clustering and replication
  • Multi-tenancy: Isolated tenant data

Quick Start

docker run -p 8428:8428 hanzo/metrics

Documentation

See the documentation for detailed guides and API reference.

License

MIT License - see LICENSE for details.

Documentation

Overview

HIP-0106 Mount() entry point for the native metrics subsystem.

import _ "github.com/hanzoai/metrics" // init() registers the subsystem

At startup the cloud binary iterates its registry and calls Mount() for each enabled subsystem, attaching /v1/metrics/* to the shared zip.App. Ingest is luxfi/metric.MetricBatch (the ZAP MsgMetricBatch payload); storage and query are native — there is no prometheus, no scrape endpoint, no /api/ path.

Package metrics is the native, ZAP-native, prometheus-free time-series store for the Hanzo cloud. It replaces the vendored Grafana/Prometheus observability backends with a small in-process store that ingests luxfi/metric.MetricBatch (the same wire shape the ZAP MsgMetricBatch transport carries) and serves range queries under /v1/metrics/*.

The storage API is deliberately tiny (Append + Query + SeriesCount) so a durable per-tenant backend (DataDir-backed, columnar) can replace the in-memory map without changing mount.go or ingest.go. There is ZERO prometheus here.

Index

Constants

View Source
const Version = "0.1.0"

Version is surfaced on /v1/metrics/health.

Variables

This section is empty.

Functions

func Mount

func Mount(app *zip.App, deps cloud.Deps) error

Mount registers the native metrics routes on the shared cloud App per HIP-0106.

Types

type Sample

type Sample struct {
	TsNs  int64   `json:"t"`
	Value float64 `json:"v"`
}

Sample is a single timestamped value. Ts is nanoseconds since the Unix epoch to match luxfi/metric.MetricBatch.TimestampNs.

type Series

type Series struct {
	Name    string            `json:"name"`
	Labels  map[string]string `json:"labels,omitempty"`
	Samples []Sample          `json:"samples"`
}

Series is a named, labeled append-only stream of samples.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is the native in-memory time-series store. Each series is bounded to maxPerSeries samples (oldest evicted first). Safe for concurrent use.

func NewStore

func NewStore() *Store

NewStore returns an empty store with a default per-series retention of 64Ki samples (a real deployment sets this from config / per-tenant quota).

func (*Store) Append

func (s *Store) Append(name string, labels map[string]string, smp Sample)

Append adds one sample to the series identified by (name, labels), creating the series on first write and evicting the oldest sample past retention.

func (*Store) IngestBatch

func (s *Store) IngestBatch(b *metric.MetricBatch) int

IngestBatch writes every sample in a luxfi/metric.MetricBatch into the store. This is the exact wire type the ZAP MsgMetricBatch transport carries, so the same code path serves both the HTTP /v1/metrics/batch endpoint and a future ZAP receiver. Counter/gauge values land directly; histogram/summary families contribute derived <name>_sum and <name>_count series. Returns samples written.

func (*Store) Query

func (s *Store) Query(name string, matchers map[string]string, startNs, endNs int64) []Series

Query returns copies of every series whose Name equals name (or all, if name is "") and whose labels are a superset of matchers, with samples restricted to [startNs, endNs] (a zero bound is treated as unbounded).

func (*Store) SeriesCount

func (s *Store) SeriesCount() int

SeriesCount reports the number of distinct series held (surfaced on /health).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL