Documentation
¶
Overview ¶
Package configurablemetrics handles the collection of arbitrary metric data in the agent, as defined by a collection definition configuration file.
Index ¶
- func BuildMetricMap(metrics []*cmpb.EvalMetric) map[string]string
- func CollectEvalMetricsFromFile(ctx context.Context, reader FileReader, path string, ...) map[string]string
- func CollectOSCommandMetric(ctx context.Context, m *cmpb.OSCommandMetric, exec commandlineexecutor.Execute, ...) (label, value string)
- func Evaluate[M proto.Message](ctx context.Context, metric M, output Output, ignoreCase bool) (string, bool)
- type FileReader
- type Output
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.