Categorygithub.com/craumix/embedded_node_exporter
modulepackage
0.0.0-20240924084923-563a0cbba5f1
Repository: https://github.com/craumix/embedded_node_exporter.git
Documentation: pkg.go.dev

# README

Embedded node_exporter

The goal of this project is to make a version of node_exporter that is easily embeddable into another golang application. While this is considered an "anti-pattern" for prometheus exporters as discussed here there are sometimes still use cases where including the exporter is the better solution.

Usage

The following example creates and registers a new NodeCollector with some basic collectors and no logging for the collectors.

import (
    exporter "github.com/craumix/embedded_node_exporter"
)

nc, err := exporter.NewNodeCollector(
    nil,
    "cpu",
    "hwmon",
    "meminfo",
    "stat",
    "diskstats",
    "netstat",
    "time",
    "filesystem",
)
if err != nil {
    log.Panic(err)
}
err = prometheus.Register(nc)
if err != nil {
    log.Panic(err)
}

The collectors use https://github.com/go-kit/log for logging so you can either use that or write a translation to your own logger. A translator for logrus is already included and may be used as an example for further use cases.

level := logrus.WarnLevel

nc, err := exporter.NewNodeCollector(
    &exporter.LogrusTranslator{
        LogLevel: &level,
    },
    "cpu",
)

The LogLevel can be optionally specified, if not set will use ur default log level.

# Functions

No description provided by the author

# Variables

--collector.filesystem.ignored-mount-points Regexp of mount points to ignore for filesystem collector.go:linkname FsTypesExclude github.com/prometheus/node_exporter/collector.fsTypesExclude.
--collector.filesystem.mount-points-exclude Regexp of mount points to exclude for filesystem collector.go:linkname MountPointsExclude github.com/prometheus/node_exporter/collector.mountPointsExclude.
--collector.netdev.device-exclude Regexp of net devices to exclude (mutually exclusive to device-include).go:linkame NetdevDeviceExclude github.com/prometheus/node_exporter/collector.netdevDeviceExclude.
--path.procfs procfs mountpoint.go:linkname ProcPath github.com/prometheus/node_exporter/collector.procPath.
--path.rootfs rootfs mountpoint.go:linkname RootfsPath github.com/prometheus/node_exporter/collector.rootfsPath.
--path.sysfs sysfs mountpoint.go:linkname SysPath github.com/prometheus/node_exporter/collector.sysPath.
--path.udev.data udev data path.go:linkname UdevDataPath github.com/prometheus/node_exporter/collector.udevDataPath.

# Structs

No description provided by the author