aggregators

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AGGREGATION_METHOD_MEDIAN = "median"
	AGGREGATION_METHOD_MODE   = "mode"
	DEVIATION_TYPE_NONE       = "none"
	DEVIATION_TYPE_PERCENT    = "percent"
	DEVIATION_TYPE_ABSOLUTE   = "absolute"
	REPORT_FORMAT_MAP         = "map"
	REPORT_FORMAT_ARRAY       = "array"
	REPORT_FORMAT_VALUE       = "value"

	DEFAULT_REPORT_FORMAT     = REPORT_FORMAT_MAP
	DEFAULT_OUTPUT_FIELD_NAME = "Reports"
)

Variables

This section is empty.

Functions

func NewIdenticalAggregator

func NewIdenticalAggregator(config values.Map) (*identicalAggregator, error)

func NewReduceAggregator

func NewReduceAggregator(config values.Map) (types.Aggregator, error)

func ParseConfigIdenticalAggregator

func ParseConfigIdenticalAggregator(config values.Map) (identicalAggConfig, error)

Types

type AggregationField

type AggregationField struct {
	// An optional check to only report when the difference from the previous report exceeds a certain threshold.
	// Can only be used when the field is of a numeric type: string, decimal, int64, big.Int, time.Time, float64
	// If no deviation is provided on any field, there will always be a report once minimum observations are reached.
	Deviation       decimal.Decimal `mapstructure:"-"  json:"-"`
	DeviationString string          `mapstructure:"deviation"  json:"deviation,omitempty"`
	// The format of the deviation being provided
	// * percent - a percentage deviation
	// * absolute - an unsigned numeric difference
	DeviationType string `mapstructure:"deviationType" json:"deviationType,omitempty" jsonschema:"enum=percent,enum=absolute,enum=none"`
	// The key to find a data point within the input data
	// If omitted, the entire input will be used
	InputKey string `mapstructure:"inputKey" json:"inputKey"`
	// How the data set should be aggregated to a single value
	// * median - take the centermost value of the sorted data set of observations. can only be used on numeric types. not a true median, because no average if two middle values.
	// * mode - take the most frequent value. if tied, use the "first".
	Method string `mapstructure:"method" json:"method" jsonschema:"enum=median,enum=mode" required:"true"`
	// The key that the aggregated data is put under
	// If omitted, the InputKey will be used
	OutputKey string `mapstructure:"outputKey" json:"outputKey"`
	// If enabled, this field will be moved from the top level map
	// into a nested map on the key defined by "SubMapKey"
	SubMapField bool `mapstructure:"subMapField"  json:"subMapField,omitempty"`
}

type ReduceAggConfig

type ReduceAggConfig struct {
	// Configuration on how to aggregate one or more data points
	Fields []AggregationField `mapstructure:"fields"  required:"true"`
	// The top level field name that report data is put into
	OutputFieldName string `mapstructure:"outputFieldName" json:"outputFieldName" default:"Reports"`
	// The structure surrounding the report data that is put on to "OutputFieldName"
	ReportFormat string `mapstructure:"reportFormat" json:"reportFormat" default:"map" jsonschema:"enum=map,enum=array,enum=value"`
	// Optional key name, that when given will contain a nested map with designated Fields moved into it
	// If given, one or more fields must be given SubMapField: true
	SubMapKey string `mapstructure:"subMapKey" json:"subMapKey" default:""`
}

func ParseConfigReduceAggregator

func ParseConfigReduceAggregator(config values.Map) (ReduceAggConfig, error)

Jump to

Keyboard shortcuts

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