configurablemetrics

package
v0.0.0-...-4729a3b Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: Apache-2.0 Imports: 11 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 CollectEvalMetricsFromFile

func CollectEvalMetricsFromFile(ctx context.Context, reader FileReader, path string, metrics []*cmpb.EvalMetric, ignoreCase bool) map[string]string

CollectEvalMetricsFromFile performs metric collection on a file path and returns the results.

Given a file path, scan through each line of the file and evaluate whether it satisfies one or more of the metrics supplied. If so, then the metric value will be set to the result of the evaluation. The `ignoreCase` parameter allows for the evaluations in the file to be case insensitive.

func CollectOSCommandMetric

func CollectOSCommandMetric(ctx context.Context, 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](ctx context.Context, metric M, output Output, ignoreCase bool) (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