configurablemetrics

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package configurablemetrics handles the collection of arbitrary metric data in the agent, as defined by a collection definition configuration file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildMetricMap

func BuildMetricMap(metrics []*cmpb.EvalMetric) map[string]string

BuildMetricMap iterates over an EvalMetric slice and returns a map of metric labels defaulted to an empty string value.

func CollectMetricsFromFile

func CollectMetricsFromFile(reader FileReader, path string, metrics []*cmpb.EvalMetric) map[string]string

CollectMetricsFromFile scans a configuration file and returns a map of collected metric values, keyed by metric label.

func CollectOSCommandMetric

func CollectOSCommandMetric(m *cmpb.OSCommandMetric, exec commandlineexecutor.Execute, vendor string) (label, value string)

CollectOSCommandMetric executes a command, evaluates the output, and returns the metric label and resulting value of the evaluation.

If a specific os_vendor is supplied for a metric, then the command will only be run if the system is using the same vendor. Otherwise, the metric should be excluded from collection.

func Evaluate

func Evaluate[M proto.Message](metric M, output Output) (string, bool)

Evaluate runs a series of evaluation rules against an Output source and returns a derived metric value, as well as a boolean indicating whether the evaluation rules were resolved as true or as false.

Types

type FileReader

type FileReader func(string) (io.ReadCloser, error)

FileReader abstracts loading and reading files into an io.ReadCloser object.

type Output

type Output struct {
	StdOut   string
	StdErr   string
	ExitCode string
}

Output holds the values of various output sources that can be evaluated.

Jump to

Keyboard shortcuts

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