metrics

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package metrics implements the tailkitd metrics integration, exposing host, CPU, memory, disk, network, and process metrics via gopsutil.

No persistent connection is needed — gopsutil reads /proc directly on Linux. Missing metrics.toml → 503 on every endpoint (invariant 5).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllMetrics

type AllMetrics struct {
	Host      *gopsutilhost.InfoStat       `json:"host,omitempty"`
	CPU       *CPUResult                   `json:"cpu,omitempty"`
	Memory    *MemoryResult                `json:"memory,omitempty"`
	Disk      []*gopsutildisk.UsageStat    `json:"disk,omitempty"`
	Network   []gopsutilnet.IOCountersStat `json:"network,omitempty"`
	Processes []ProcessStat                `json:"processes,omitempty"`
}

AllMetrics bundles every enabled metric into a single response. This lets callers fetch everything in one round trip.

type CPUResult

type CPUResult struct {
	Info    []gopsutilcpu.InfoStat `json:"info"`
	Percent []float64              `json:"percent_per_cpu"`
	Total   float64                `json:"percent_total"`
}

CPUResult bundles per-CPU usage percentages with static CPU info.

type Handler

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

Handler serves all /integrations/metrics/* endpoints.

func NewHandler

func NewHandler(cfg config.MetricsConfig, logger *zap.Logger) *Handler

NewHandler constructs a metrics Handler.

func (*Handler) Register

func (h *Handler) Register(mux *http.ServeMux)

Register mounts all metrics endpoints onto mux.

GET /integrations/metrics/available
GET /integrations/metrics/config
GET /integrations/metrics/host
GET /integrations/metrics/cpu
GET /integrations/metrics/memory
GET /integrations/metrics/disk
GET /integrations/metrics/network
GET /integrations/metrics/processes
GET /integrations/metrics/all

type MemoryResult

type MemoryResult struct {
	Virtual *gopsutilmem.VirtualMemoryStat `json:"virtual"`
	Swap    *gopsutilmem.SwapMemoryStat    `json:"swap"`
}

MemoryResult bundles virtual and swap memory stats.

type ProcessStat

type ProcessStat struct {
	PID        int32   `json:"pid"`
	Name       string  `json:"name"`
	Status     string  `json:"status"`
	CPUPercent float64 `json:"cpu_percent"`
	MemoryRSS  uint64  `json:"memory_rss_bytes"`
	Cmdline    string  `json:"cmdline"`
}

ProcessStat is the per-process summary returned in the processes response. We define our own struct to control exactly which fields are exposed and to avoid serialising the full gopsutil Process object with its internal state.

Jump to

Keyboard shortcuts

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