Documentation
¶
Overview ¶
Package host collects host and process metrics with OTel semantic-convention names, through gopsutil (pure Go, no cgo, Linux/Windows/macOS).
Index ¶
- Constants
- func Collect(out sink.Sink, d Discovery, at time.Time)
- func CollectDepth(out sink.Sink, at time.Time)
- func CollectKernel(out sink.Sink, root string, at time.Time)
- func Duration(s string, def, floor time.Duration) time.Duration
- func EmitCPUTimes(out sink.Sink, ts []cpu.TimesStat, at time.Time)
- func EmitDiskDepth(out sink.Sink, d Discovery, stats map[string]disk.IOCountersStat, at time.Time)
- func EmitFilesystems(out sink.Sink, d Discovery, fss []FS, at time.Time)
- func EmitHwmon(out sink.Sink, dir string, at time.Time)
- func EmitIO(out sink.Sink, d Discovery, kind, name string, devs map[string][2]uint64, ...)
- func EmitMeminfoDepth(out sink.Sink, r io.Reader, at time.Time)
- func EmitNICDepth(out sink.Sink, d Discovery, nics []gnet.IOCountersStat, at time.Time)
- func EmitProcStat(out sink.Sink, r io.Reader, at time.Time)
- func EmitProcesses(out sink.Sink, samples []ProcSample, prev map[int32]float64, ...) map[int32]float64
- func EmitSelected(out sink.Sink, samples []ProcSample, globs []string, at time.Time)
- func Every(ctx context.Context, interval time.Duration, fn func(ctx context.Context))
- func ParseProcNetTCP(r io.Reader, counts map[string]int)
- func ParseSNMP(r io.Reader) map[string]float64
- func Redact(err error, secrets ...string) error
- func Run(ctx context.Context, raw json.RawMessage, out sink.Sink) error
- func Warn(key string, err error)
- func WrapEmit(out sink.Sink, mode string) sink.Sink
- type Config
- type Discovery
- type FS
- type NodeAliasSink
- type Object
- type ProcSample
- type Processes
- type Rule
Constants ¶
const ( EmitOTel = "otel" // semconv names only (default) EmitNodeExporter = "node_exporter" // node_* names only EmitBoth = "both" )
Emit modes for Config.Emit.
const ( KindFilesystem = "filesystem" KindDisk = "disk" KindNIC = "nic" KindGPU = "gpu" )
Kinds that low-level discovery can enumerate.
const MaxProcesses = 50
MaxProcesses caps each process list (top by CPU, top by memory). Live agent-served process views are known gap G-24; this is sampled metrics only.
Variables ¶
This section is empty.
Functions ¶
func CollectDepth ¶
CollectDepth adds the node_exporter-depth series: per-core and per-mode CPU time, paging and swap, process counts, context switches and TCP connection states.
func CollectKernel ¶
CollectKernel emits the kernel inputs on Linux; elsewhere it does nothing.
func EmitCPUTimes ¶
EmitCPUTimes writes system.cpu.time per logical CPU and mode (cumulative seconds).
func EmitDiskDepth ¶
EmitDiskDepth writes operation counts, operation time, busy time and queue depth per disk.
func EmitFilesystems ¶
EmitFilesystems writes system.filesystem.usage for each filesystem the discovery rules allow. The parent host is not stamped: the worker derives it from the resource host.name.
func EmitHwmon ¶
EmitHwmon writes hw.temperature (degrees Celsius) for every hwmon temp*_input sensor.
func EmitIO ¶
func EmitIO(out sink.Sink, d Discovery, kind, name string, devs map[string][2]uint64, dirs [2]string, at time.Time)
EmitIO writes a cumulative byte counter per device and direction (dirs[0] for vals[0]).
func EmitMeminfoDepth ¶
EmitMeminfoDepth writes huge pages and slab memory from /proc/meminfo.
func EmitNICDepth ¶
EmitNICDepth writes packets, errors and drops per interface and direction.
func EmitProcStat ¶
EmitProcStat writes the interrupt total (`intr`), soft interrupts and boot time from /proc/stat.
func EmitProcesses ¶
func EmitProcesses(out sink.Sink, samples []ProcSample, prev map[int32]float64, elapsed time.Duration, at time.Time) map[int32]float64
EmitProcesses writes process.cpu.utilization for the top processes by CPU (a fraction of all cores, from the change since prev over elapsed) and process.memory.usage for the top by memory. It returns the new cumulative CPU map.
func EmitSelected ¶
EmitSelected writes process.cpu.time and process.memory.usage for every process whose executable name matches one of the globs (Telegraf procstat selection), top-N or not.
func ParseProcNetTCP ¶
ParseProcNetTCP adds the sockets of one /proc/net/tcp-format table to counts by state name.
func ParseSNMP ¶
ParseSNMP reads /proc/net/snmp (a header line and a value line per protocol) into nstat names.
func Redact ¶
Redact returns err with every non-empty secret replaced, so a credential a library echoes in an error never reaches a log, a label or the wire.
Types ¶
type Config ¶
type Config struct {
Enabled *bool `json:"enabled"`
Interval string `json:"interval"` // default 10s, at least 1s
ProcessInterval string `json:"process_interval"` // default 30s, at least 5s
Processes *bool `json:"processes"` // default true
ProcessNames []string `json:"process_names"` // globs of executable names always reported (procstat)
Discovery Discovery `json:"discovery"`
Emit string `json:"emit"` // otel (default), node_exporter or both
}
Config is the host module's config. Only Enabled and Interval can be set remotely.
func ParseConfig ¶
func ParseConfig(raw json.RawMessage) (Config, error)
ParseConfig decodes and validates cfg (empty means defaults).
type Discovery ¶
type Discovery []Rule
Discovery is the list of rules. A kind without a rule is collected whole.
type FS ¶
type FS struct {
Device, Mount, Type string
Used, Free uint64
// InodesUsed and InodesFree are 0 on filesystems without inodes (FAT, NTFS via gopsutil).
InodesUsed, InodesFree uint64
}
FS is one mounted filesystem.
type NodeAliasSink ¶
NodeAliasSink forwards to Inner and also (or only, when OnlyAlias) writes the node_exporter name for each sample that has one. A sample with no alias is always forwarded.
type ProcSample ¶
type ProcSample struct {
PID int32
Name string
CPUSecs float64 // cumulative user+system seconds
RSS uint64
}
ProcSample is one process at one sample.
func TopN ¶
func TopN(in []ProcSample, key func(ProcSample) float64) []ProcSample
TopN returns at most MaxProcesses samples with the largest key, largest first. Ties break by pid so the result is stable.
type Processes ¶
type Processes struct {
// contains filtered or unexported fields
}
Processes samples the process table on its own, slower, schedule.
func NewProcesses ¶
NewProcesses returns a sampler that runs at most once per every.
type Rule ¶
type Rule struct {
Kind string `json:"kind"`
Include []string `json:"include"`
Exclude []string `json:"exclude"`
}
Rule is one low-level discovery rule (INF-020). Include and Exclude are path.Match globs against the child's name (mount point, device, interface or GPU index). No include means all; exclude wins.