collector

package
v3.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2024 License: Apache-2.0, Apache-2.0 Imports: 47 Imported by: 0

Documentation

Overview

Package collector includes all individual collectors to gather and export system metrics.

Index

Constants

View Source
const (
	ANCHORED        = C.PCRE_ANCHORED
	BSR_ANYCRLF     = C.PCRE_BSR_ANYCRLF
	BSR_UNICODE     = C.PCRE_BSR_UNICODE
	NEWLINE_ANY     = C.PCRE_NEWLINE_ANY
	NEWLINE_ANYCRLF = C.PCRE_NEWLINE_ANYCRLF
	NEWLINE_CR      = C.PCRE_NEWLINE_CR
	NEWLINE_CRLF    = C.PCRE_NEWLINE_CRLF
	NEWLINE_LF      = C.PCRE_NEWLINE_LF
	NO_UTF8_CHECK   = C.PCRE_NO_UTF8_CHECK
)

Flags for Compile and Match functions.

View Source
const (
	CASELESS          = C.PCRE_CASELESS
	DOLLAR_ENDONLY    = C.PCRE_DOLLAR_ENDONLY
	DOTALL            = C.PCRE_DOTALL
	DUPNAMES          = C.PCRE_DUPNAMES
	EXTENDED          = C.PCRE_EXTENDED
	EXTRA             = C.PCRE_EXTRA
	FIRSTLINE         = C.PCRE_FIRSTLINE
	JAVASCRIPT_COMPAT = C.PCRE_JAVASCRIPT_COMPAT
	MULTILINE         = C.PCRE_MULTILINE
	NO_AUTO_CAPTURE   = C.PCRE_NO_AUTO_CAPTURE
	UNGREEDY          = C.PCRE_UNGREEDY
	UTF8              = C.PCRE_UTF8
)

Flags for Compile functions

View Source
const (
	NOTBOL            = C.PCRE_NOTBOL
	NOTEOL            = C.PCRE_NOTEOL
	NOTEMPTY          = C.PCRE_NOTEMPTY
	NOTEMPTY_ATSTART  = C.PCRE_NOTEMPTY_ATSTART
	NO_START_OPTIMIZE = C.PCRE_NO_START_OPTIMIZE
	PARTIAL_HARD      = C.PCRE_PARTIAL_HARD
	PARTIAL_SOFT      = C.PCRE_PARTIAL_SOFT
)

Flags for Match functions

Variables

View Source
var ErrNoData = errors.New("collector returned no data")

ErrNoData indicates the collector found no data to collect, but had no other error.

View Source
var ProcessJob processMonitorJob

Functions

func DisableDefaultCollectors added in v1.8.0

func DisableDefaultCollectors()

DisableDefaultCollectors sets the collector state to false for all collectors which have not been explicitly enabled on the command line.

func HandleProcessAction

func HandleProcessAction(requestParamBuff []byte) (isCheck bool, err error)

func InitMonitorLogger

func InitMonitorLogger(logger log.Logger)

func IsNoDataError added in v1.8.0

func IsNoDataError(err error) bool

func LogKeyWordLoadConfig

func LogKeyWordLoadConfig()

func LogKeywordHttpHandle

func LogKeywordHttpHandle(w http.ResponseWriter, r *http.Request)

func LogMetricLoadConfig

func LogMetricLoadConfig()

func LogMetricMonitorHandleAction

func LogMetricMonitorHandleAction(requestParamBuff []byte) error

func LogMetricMonitorHttpHandle

func LogMetricMonitorHttpHandle(w http.ResponseWriter, r *http.Request)

func LogMetricSaveConfig

func LogMetricSaveConfig(requestParamBuff []byte)

func LogMonitorRowsHttpHandle added in v1.8.0

func LogMonitorRowsHttpHandle(w http.ResponseWriter, r *http.Request)

func PcreCompile

func PcreCompile(pattern string, flags int) (Regexp, *CompileError)

Try to compile the pattern. If an error occurs, the second return value is non-nil.

func ProcessHttpHandle

func ProcessHttpHandle(w http.ResponseWriter, r *http.Request)

func StartCalcLogMetricCron

func StartCalcLogMetricCron()

func StartProcessMonitorCron

func StartProcessMonitorCron()

Types

type Collector

type Collector interface {
	// Get new metrics and expose them via prometheus registry.
	Update(ch chan<- prometheus.Metric) error
}

Collector is the interface a collector has to implement.

func LogMetricMonitorCollector

func LogMetricMonitorCollector(logger log.Logger) (Collector, error)

func NewARPCollector

func NewARPCollector(logger log.Logger) (Collector, error)

NewARPCollector returns a new Collector exposing ARP stats.

func NewBcacheCollector

func NewBcacheCollector(logger log.Logger) (Collector, error)

NewBcacheCollector returns a newly allocated bcacheCollector. It exposes a number of Linux bcache statistics.

func NewBondingCollector

func NewBondingCollector(logger log.Logger) (Collector, error)

NewBondingCollector returns a newly allocated bondingCollector. It exposes the number of configured and active slave of linux bonding interfaces.

func NewBtrfsCollector added in v1.8.0

func NewBtrfsCollector(logger log.Logger) (Collector, error)

NewBtrfsCollector returns a new Collector exposing Btrfs statistics.

func NewBuddyinfoCollector

func NewBuddyinfoCollector(logger log.Logger) (Collector, error)

NewBuddyinfoCollector returns a new Collector exposing buddyinfo stats.

func NewCPUCollector

func NewCPUCollector(logger log.Logger) (Collector, error)

NewCPUCollector returns a new Collector exposing kernel/system statistics.

func NewCPUFreqCollector

func NewCPUFreqCollector(logger log.Logger) (Collector, error)

NewCPUFreqCollector returns a new Collector exposing kernel/system statistics.

func NewConntrackCollector

func NewConntrackCollector(logger log.Logger) (Collector, error)

NewConntrackCollector returns a new Collector exposing conntrack stats.

func NewDiskstatsCollector

func NewDiskstatsCollector(logger log.Logger) (Collector, error)

NewDiskstatsCollector returns a new Collector exposing disk device stats. Docs from https://www.kernel.org/doc/Documentation/iostats.txt

func NewEdacCollector

func NewEdacCollector(logger log.Logger) (Collector, error)

NewEdacCollector returns a new Collector exposing edac stats.

func NewEntropyCollector

func NewEntropyCollector(logger log.Logger) (Collector, error)

NewEntropyCollector returns a new Collector exposing entropy stats.

func NewFileFDStatCollector

func NewFileFDStatCollector(logger log.Logger) (Collector, error)

NewFileFDStatCollector returns a new Collector exposing file-nr stats.

func NewFilesystemCollector

func NewFilesystemCollector(logger log.Logger) (Collector, error)

NewFilesystemCollector returns a new Collector exposing filesystems stats.

func NewHwMonCollector

func NewHwMonCollector(logger log.Logger) (Collector, error)

NewHwMonCollector returns a new Collector exposing /sys/class/hwmon stats (similar to lm-sensors).

func NewIPVSCollector

func NewIPVSCollector(logger log.Logger) (Collector, error)

NewIPVSCollector sets up a new collector for IPVS metrics. It accepts the "procfs" config parameter to override the default proc location (/proc).

func NewInfiniBandCollector

func NewInfiniBandCollector(logger log.Logger) (Collector, error)

NewInfiniBandCollector returns a new Collector exposing InfiniBand stats.

func NewInterruptsCollector

func NewInterruptsCollector(logger log.Logger) (Collector, error)

NewInterruptsCollector returns a new Collector exposing interrupts stats.

func NewKsmdCollector

func NewKsmdCollector(logger log.Logger) (Collector, error)

NewKsmdCollector returns a new Collector exposing kernel/system statistics.

func NewLoadavgCollector

func NewLoadavgCollector(logger log.Logger) (Collector, error)

NewLoadavgCollector returns a new Collector exposing load average stats.

func NewLogMonitorCollector

func NewLogMonitorCollector(logger log.Logger) (Collector, error)

func NewLogindCollector

func NewLogindCollector(logger log.Logger) (Collector, error)

NewLogindCollector returns a new Collector exposing logind statistics.

func NewMdadmCollector

func NewMdadmCollector(logger log.Logger) (Collector, error)

NewMdadmCollector returns a new Collector exposing raid statistics.

func NewMeminfoCollector

func NewMeminfoCollector(logger log.Logger) (Collector, error)

NewMeminfoCollector returns a new Collector exposing memory stats.

func NewMeminfoNumaCollector

func NewMeminfoNumaCollector(logger log.Logger) (Collector, error)

NewMeminfoNumaCollector returns a new Collector exposing memory stats.

func NewMountStatsCollector

func NewMountStatsCollector(logger log.Logger) (Collector, error)

NewMountStatsCollector returns a new Collector exposing NFS statistics.

func NewNFSdCollector

func NewNFSdCollector(logger log.Logger) (Collector, error)

NewNFSdCollector returns a new Collector exposing /proc/net/rpc/nfsd statistics.

func NewNetClassCollector

func NewNetClassCollector(logger log.Logger) (Collector, error)

NewNetClassCollector returns a new Collector exposing network class stats.

func NewNetDevCollector

func NewNetDevCollector(logger log.Logger) (Collector, error)

NewNetDevCollector returns a new Collector exposing network device stats.

func NewNetStatCollector

func NewNetStatCollector(logger log.Logger) (Collector, error)

NewNetStatCollector takes and returns a new Collector exposing network stats.

func NewNfsCollector

func NewNfsCollector(logger log.Logger) (Collector, error)

NewNfsCollector returns a new Collector exposing NFS statistics.

func NewNtpCollector

func NewNtpCollector(logger log.Logger) (Collector, error)

NewNtpCollector returns a new Collector exposing sanity of local NTP server. Default definition of "local" is: - collector.ntp.server address is a loopback address (or collector.ntp.server-is-mine flag is turned on) - the server is reachable with outgoin IP_TTL = 1

func NewPerfCollector

func NewPerfCollector(logger log.Logger) (Collector, error)

NewPerfCollector returns a new perf based collector, it creates a profiler per CPU.

func NewPowerSupplyClassCollector added in v1.8.0

func NewPowerSupplyClassCollector(logger log.Logger) (Collector, error)

func NewPressureStatsCollector

func NewPressureStatsCollector(logger log.Logger) (Collector, error)

NewPressureStatsCollector returns a Collector exposing pressure stall information

func NewProcessMonitorCollector

func NewProcessMonitorCollector(logger log.Logger) (Collector, error)

func NewProcessStatCollector

func NewProcessStatCollector(logger log.Logger) (Collector, error)

NewProcessStatCollector returns a new Collector exposing process data read from the proc filesystem.

func NewQdiscStatCollector

func NewQdiscStatCollector(logger log.Logger) (Collector, error)

NewQdiscStatCollector returns a new Collector exposing queuing discipline statistics.

func NewRaplCollector added in v1.8.0

func NewRaplCollector(logger log.Logger) (Collector, error)

NewRaplCollector returns a new Collector exposing RAPL metrics.

func NewRunitCollector

func NewRunitCollector(logger log.Logger) (Collector, error)

NewRunitCollector returns a new Collector exposing runit statistics.

func NewSchedstatCollector

func NewSchedstatCollector(logger log.Logger) (Collector, error)

NewSchedstatCollector returns a new Collector exposing task scheduler statistics

func NewSockStatCollector

func NewSockStatCollector(logger log.Logger) (Collector, error)

NewSockStatCollector returns a new Collector exposing socket stats.

func NewSoftnetCollector added in v1.8.0

func NewSoftnetCollector(logger log.Logger) (Collector, error)

NewSoftnetCollector returns a new Collector exposing softnet metrics.

func NewStatCollector

func NewStatCollector(logger log.Logger) (Collector, error)

NewStatCollector returns a new Collector exposing kernel/system statistics.

func NewSupervisordCollector

func NewSupervisordCollector(logger log.Logger) (Collector, error)

NewSupervisordCollector returns a new Collector exposing supervisord statistics.

func NewSystemdCollector

func NewSystemdCollector(logger log.Logger) (Collector, error)

NewSystemdCollector returns a new Collector exposing systemd statistics.

func NewTCPStatCollector

func NewTCPStatCollector(logger log.Logger) (Collector, error)

NewTCPStatCollector returns a new Collector exposing network stats.

func NewTextFileCollector

func NewTextFileCollector(logger log.Logger) (Collector, error)

NewTextFileCollector returns a new Collector exposing metrics read from files in the given textfile directory.

func NewThermalZoneCollector

func NewThermalZoneCollector(logger log.Logger) (Collector, error)

NewThermalZoneCollector returns a new Collector exposing kernel/system statistics.

func NewTimeCollector

func NewTimeCollector(logger log.Logger) (Collector, error)

NewTimeCollector returns a new Collector exposing the current system time in seconds since epoch.

func NewTimexCollector

func NewTimexCollector(logger log.Logger) (Collector, error)

NewTimexCollector returns a new Collector exposing adjtime(3) stats.

func NewUDPqueuesCollector added in v1.8.0

func NewUDPqueuesCollector(logger log.Logger) (Collector, error)

NewUDPqueuesCollector returns a new Collector exposing network udp queued bytes.

func NewWifiCollector

func NewWifiCollector(logger log.Logger) (Collector, error)

NewWifiCollector returns a new Collector exposing Wifi statistics.

func NewXFSCollector

func NewXFSCollector(logger log.Logger) (Collector, error)

NewXFSCollector returns a new Collector exposing XFS statistics.

func NewZFSCollector

func NewZFSCollector(logger log.Logger) (Collector, error)

NewZFSCollector returns a new Collector exposing ZFS statistics.

func NewvmStatCollector

func NewvmStatCollector(logger log.Logger) (Collector, error)

NewvmStatCollector returns a new Collector exposing vmstat stats.

type CompileError

type CompileError struct {
	Pattern string
	Message string
	Offset  int
}

A compilation error, as returned by the Compile function. The offset is the byte position in the pattern string at which the error was detected.

func (*CompileError) String

func (e *CompileError) String() string

type LogMetricConfigTag

type LogMetricConfigTag struct {
	Key          string         `json:"key"`
	Regular      string         `json:"regular"`
	RegExp       *regexp.Regexp `json:"-"`
	LogParamName string         `json:"log_param_name"`
}

type Matcher

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

Matcher objects provide a place for storing match results. They can be created by the Matcher and MatcherString functions, or they can be initialized with Reset or ResetString.

func (*Matcher) Group

func (m *Matcher) Group(group int) []byte

Returns the numbered capture group of the last match (performed by Matcher, MatcherString, Reset, ResetString, Match, or MatchString). Group 0 is the part of the subject which matches the whole pattern; the first actual capture group is numbered 1. Capture groups which are not present return a nil slice.

func (*Matcher) GroupString

func (m *Matcher) GroupString(group int) string

Returns the numbered capture group as a string. Group 0 is the part of the subject which matches the whole pattern; the first actual capture group is numbered 1. Capture groups which are not present return an empty string.

func (*Matcher) Groups

func (m *Matcher) Groups() int

Returns the number of groups in the current pattern.

func (*Matcher) Match

func (m *Matcher) Match(subject []byte, flags int) bool

Tries to match the speficied byte array slice to the current pattern. Returns true if the match succeeds.

func (*Matcher) MatchString

func (m *Matcher) MatchString(subject string, flags int) bool

Tries to match the speficied subject string to the current pattern. Returns true if the match succeeds.

func (*Matcher) Matches

func (m *Matcher) Matches() bool

Returns true if a previous call to Matcher, MatcherString, Reset, ResetString, Match or MatchString succeeded.

func (*Matcher) Named

func (m *Matcher) Named(group string) []byte

Returns the value of the named capture group. This is a nil slice if the capture group is not present. Panics if the name does not refer to a group.

func (*Matcher) NamedPresent

func (m *Matcher) NamedPresent(group string) bool

Returns true if the named capture group is present. Panics if the name does not refer to a group.

func (*Matcher) NamedString

func (m *Matcher) NamedString(group string) string

Returns the value of the named capture group, or an empty string if the capture group is not present. Panics if the name does not refer to a group.

func (*Matcher) Present

func (m *Matcher) Present(group int) bool

Returns true if the numbered capture group is present in the last match (performed by Matcher, MatcherString, Reset, ResetString, Match, or MatchString). Group numbers start at 1. A capture group can be present and match the empty string.

func (*Matcher) Reset

func (m *Matcher) Reset(re Regexp, subject []byte, flags int)

Switches the matcher object to the specified pattern and subject.

func (*Matcher) ResetString

func (m *Matcher) ResetString(re Regexp, subject string, flags int)

Switches the matcher object to the specified pattern and subject string.

type NodeCollector

type NodeCollector struct {
	Collectors map[string]Collector
	// contains filtered or unexported fields
}

NodeCollector implements the prometheus.Collector interface.

func NewNodeCollector

func NewNodeCollector(logger log.Logger, filters ...string) (*NodeCollector, error)

NewNodeCollector creates a new NodeCollector.

func (NodeCollector) Collect

func (n NodeCollector) Collect(ch chan<- prometheus.Metric)

Collect implements the prometheus.Collector interface.

func (NodeCollector) Describe

func (n NodeCollector) Describe(ch chan<- *prometheus.Desc)

Describe implements the prometheus.Collector interface.

type Regexp

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

A reference to a compiled regular expression. Use Compile or MustCompile to create such objects.

func MustPcreCompile

func MustPcreCompile(pattern string, flags int) (re Regexp)

Compile the pattern. If compilation fails, panic.

func (*Regexp) FindAllIndex

func (re *Regexp) FindAllIndex(bytes []byte, flags int) (r [][]int)

func (*Regexp) FindIndex

func (re *Regexp) FindIndex(bytes []byte, flags int) []int

Return the start and end of the first match, or nil if no match. loc[0] is the start and loc[1] is the end.

func (Regexp) Groups

func (re Regexp) Groups() int

Returns the number of capture groups in the compiled pattern.

func (Regexp) Matcher

func (re Regexp) Matcher(subject []byte, flags int) (m *Matcher)

Returns a new matcher object, with the byte array slice as a subject.

func (Regexp) MatcherString

func (re Regexp) MatcherString(subject string, flags int) (m *Matcher)

Returns a new matcher object, with the specified subject string.

func (Regexp) ReplaceAll

func (re Regexp) ReplaceAll(bytes, repl []byte, flags int) []byte

Return a copy of a byte slice with pattern matches replaced by repl.

Jump to

Keyboard shortcuts

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