metrics

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 25 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 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 ListenPort added in v0.3.5

type ListenPort struct {
	Addr    string `json:"addr"`
	Port    uint16 `json:"port"`
	Proto   string `json:"proto"`
	PID     int    `json:"pid"`
	Process string `json:"process"`
}

type MemoryResult

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

MemoryResult bundles virtual and swap memory stats.

type PortEvent added in v0.3.5

type PortEvent struct {
	Kind string     `json:"kind"`
	Port ListenPort `json:"port"`
}

type PortsSnapshotEvent added in v0.3.5

type PortsSnapshotEvent struct {
	Kind  string       `json:"kind"`
	Ports []ListenPort `json:"ports"`
}

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