models

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Default size of metrics batch size.
	DEFAULT_METRIC_BATCH_SIZE = 1000

	// Default number of metrics kept. It should be a multiple of batch size.
	DEFAULT_METRIC_BUFFER_LIMIT = 10000
)

Variables

View Source
var (
	AgentMetricsWritten = selfstat.Register("agent", "metrics_written", map[string]string{})
	AgentMetricsDropped = selfstat.Register("agent", "metrics_dropped", map[string]string{})
)
View Source
var (
	GlobalMetricsGathered = selfstat.Register("agent", "metrics_gathered", map[string]string{})
	GlobalGatherErrors    = selfstat.Register("agent", "gather_errors", map[string]string{})
)

Functions

This section is empty.

Types

type AggregatorConfig added in v1.14.0

type AggregatorConfig struct {
	Name         string
	Alias        string
	DropOriginal bool
	Period       time.Duration
	Delay        time.Duration
	Grace        time.Duration

	NameOverride      string
	MeasurementPrefix string
	MeasurementSuffix string
	Tags              map[string]string
	Filter            Filter
}

AggregatorConfig is the common config for all aggregators.

type Buffer added in v1.14.0

type Buffer struct {
	sync.Mutex

	MetricsAdded   selfstat.Stat
	MetricsWritten selfstat.Stat
	MetricsDropped selfstat.Stat
	BufferSize     selfstat.Stat
	BufferLimit    selfstat.Stat
	// contains filtered or unexported fields
}

Buffer stores metrics in a circular buffer.

func NewBuffer added in v1.14.0

func NewBuffer(name string, alias string, capacity int) *Buffer

NewBuffer returns a new empty Buffer with the given capacity.

func (*Buffer) Accept added in v1.14.0

func (b *Buffer) Accept(batch []telegraf.Metric)

Accept marks the batch, acquired from Batch(), as successfully written.

func (*Buffer) Add added in v1.14.0

func (b *Buffer) Add(metrics ...telegraf.Metric) int

Add adds metrics to the buffer and returns number of dropped metrics.

func (*Buffer) Batch added in v1.14.0

func (b *Buffer) Batch(batchSize int) []telegraf.Metric

Batch returns a slice containing up to batchSize of the most recently added metrics. Metrics are ordered from newest to oldest in the batch. The batch must not be modified by the client.

func (*Buffer) Len added in v1.14.0

func (b *Buffer) Len() int

Len returns the number of metrics currently in the buffer.

func (*Buffer) Reject added in v1.14.0

func (b *Buffer) Reject(batch []telegraf.Metric)

Reject returns the batch, acquired from Batch(), to the buffer and marks it as unsent.

type Filter

type Filter struct {
	NameDrop []string

	NamePass []string

	FieldDrop []string

	FieldPass []string

	TagDrop []TagFilter
	TagPass []TagFilter

	TagExclude []string

	TagInclude []string
	// contains filtered or unexported fields
}

Filter containing drop/pass and tagdrop/tagpass rules

func (*Filter) Compile added in v1.14.0

func (f *Filter) Compile() error

Compile all Filter lists into filter.Filter objects.

func (*Filter) IsActive

func (f *Filter) IsActive() bool

IsActive checking if filter is active

func (*Filter) Modify added in v1.14.0

func (f *Filter) Modify(metric telegraf.Metric)

Modify removes any tags and fields from the metric according to the fieldpass/fielddrop and taginclude/tagexclude filters.

func (*Filter) Select added in v1.14.0

func (f *Filter) Select(metric telegraf.Metric) bool

Select returns true if the metric matches according to the namepass/namedrop and tagpass/tagdrop filters. The metric is not modified.

type InputConfig

type InputConfig struct {
	Name     string
	Alias    string
	Interval time.Duration

	NameOverride      string
	MeasurementPrefix string
	MeasurementSuffix string
	Tags              map[string]string
	Filter            Filter
}

InputConfig is the common config for all inputs.

type Logger added in v1.14.0

type Logger struct {
	OnErrs []func()
	Name   string // Name is the plugin name, will be printed in the `[]`.
}

Logger defines a logging structure for plugins.

func NewLogger added in v1.14.0

func NewLogger(pluginType, name, alias string) *Logger

NewLogger creates a new logger instance

func (*Logger) Debug added in v1.14.0

func (l *Logger) Debug(args ...interface{})

Debug logs a debug message, patterned after log.Print.

func (*Logger) Debugf added in v1.14.0

func (l *Logger) Debugf(format string, args ...interface{})

Debugf logs a debug message, patterned after log.Printf.

func (*Logger) Error added in v1.14.0

func (l *Logger) Error(args ...interface{})

Error logs an error message, patterned after log.Print.

func (*Logger) Errorf added in v1.14.0

func (l *Logger) Errorf(format string, args ...interface{})

Errorf logs an error message, patterned after log.Printf.

func (*Logger) Info added in v1.14.0

func (l *Logger) Info(args ...interface{})

Info logs an information message, patterned after log.Print.

func (*Logger) Infof added in v1.14.0

func (l *Logger) Infof(format string, args ...interface{})

Infof logs an information message, patterned after log.Printf.

func (*Logger) OnErr added in v1.14.0

func (l *Logger) OnErr(f func())

OnErr defines a callback that triggers only when errors are about to be written to the log

func (*Logger) Warn added in v1.14.0

func (l *Logger) Warn(args ...interface{})

Warn logs a warning message, patterned after log.Print.

func (*Logger) Warnf added in v1.14.0

func (l *Logger) Warnf(format string, args ...interface{})

Warnf logs a warning message, patterned after log.Printf.

type OutputConfig

type OutputConfig struct {
	Name   string
	Alias  string
	Filter Filter

	FlushInterval     time.Duration
	FlushJitter       *time.Duration
	MetricBufferLimit int
	MetricBatchSize   int

	NameOverride string
	NamePrefix   string
	NameSuffix   string
}

OutputConfig containing name and filter

type ProcessorConfig added in v1.14.0

type ProcessorConfig struct {
	Name   string
	Alias  string
	Order  int64
	Filter Filter
}

FilterConfig containing a name and filter

type RunningAggregator added in v1.14.0

type RunningAggregator struct {
	sync.Mutex
	Aggregator telegraf.Aggregator
	Config     *AggregatorConfig

	MetricsPushed   selfstat.Stat
	MetricsFiltered selfstat.Stat
	MetricsDropped  selfstat.Stat
	PushTime        selfstat.Stat
	// contains filtered or unexported fields
}

func NewRunningAggregator added in v1.14.0

func NewRunningAggregator(aggregator telegraf.Aggregator, config *AggregatorConfig) *RunningAggregator

func (*RunningAggregator) Add added in v1.14.0

Add a metric to the aggregator and return true if the original metric should be dropped.

func (*RunningAggregator) EndPeriod added in v1.14.0

func (r *RunningAggregator) EndPeriod() time.Time

func (*RunningAggregator) Init added in v1.14.0

func (r *RunningAggregator) Init() error

func (*RunningAggregator) Log added in v1.14.0

func (*RunningAggregator) LogName added in v1.14.0

func (r *RunningAggregator) LogName() string

func (*RunningAggregator) MakeMetric added in v1.14.0

func (r *RunningAggregator) MakeMetric(metric telegraf.Metric) telegraf.Metric

func (*RunningAggregator) Period added in v1.14.0

func (r *RunningAggregator) Period() time.Duration

func (*RunningAggregator) Push added in v1.14.0

func (r *RunningAggregator) Push(acc telegraf.Accumulator)

func (*RunningAggregator) UpdateWindow added in v1.14.0

func (r *RunningAggregator) UpdateWindow(start, until time.Time)

type RunningInput

type RunningInput struct {
	Input  telegraf.Input
	Config *InputConfig

	MetricsGathered selfstat.Stat
	GatherTime      selfstat.Stat
	// contains filtered or unexported fields
}

func NewRunningInput added in v1.14.0

func NewRunningInput(input telegraf.Input, config *InputConfig) *RunningInput

func (*RunningInput) Gather added in v1.14.0

func (r *RunningInput) Gather(acc telegraf.Accumulator) error

func (*RunningInput) Init added in v1.14.0

func (r *RunningInput) Init() error

func (*RunningInput) Log added in v1.14.0

func (r *RunningInput) Log() telegraf.Logger

func (*RunningInput) LogName added in v1.14.0

func (r *RunningInput) LogName() string

func (*RunningInput) MakeMetric added in v1.14.0

func (r *RunningInput) MakeMetric(metric telegraf.Metric) telegraf.Metric

func (*RunningInput) SetDefaultTags added in v1.14.0

func (r *RunningInput) SetDefaultTags(tags map[string]string)

type RunningOutput

type RunningOutput struct {
	Output            telegraf.Output
	Config            *OutputConfig
	MetricBufferLimit int
	MetricBatchSize   int

	MetricsFiltered selfstat.Stat
	WriteTime       selfstat.Stat

	BatchReady chan time.Time
	// contains filtered or unexported fields
}

RunningOutput contains the output configuration

func NewRunningOutput

func NewRunningOutput(
	name string,
	output telegraf.Output,
	config *OutputConfig,
	batchSize int,
	bufferLimit int,
) *RunningOutput

func (*RunningOutput) AddMetric added in v1.14.0

func (ro *RunningOutput) AddMetric(metric telegraf.Metric)

AddMetric adds a metric to the output.

Takes ownership of metric

func (*RunningOutput) Close added in v1.14.0

func (r *RunningOutput) Close()

Close closes the output

func (*RunningOutput) Init added in v1.14.0

func (r *RunningOutput) Init() error

func (*RunningOutput) Log added in v1.14.0

func (r *RunningOutput) Log() telegraf.Logger

func (*RunningOutput) LogBufferStatus added in v1.14.0

func (r *RunningOutput) LogBufferStatus()

func (*RunningOutput) LogName added in v1.14.0

func (r *RunningOutput) LogName() string

func (*RunningOutput) Write

func (ro *RunningOutput) Write() error

Write writes all metrics to the output, stopping when all have been sent on or error.

func (*RunningOutput) WriteBatch added in v1.14.0

func (ro *RunningOutput) WriteBatch() error

WriteBatch writes a single batch of metrics to the output.

type RunningProcessor added in v1.14.0

type RunningProcessor struct {
	sync.Mutex

	Processor telegraf.Processor
	Config    *ProcessorConfig
	// contains filtered or unexported fields
}

func NewRunningProcessor added in v1.14.0

func NewRunningProcessor(processor telegraf.Processor, config *ProcessorConfig) *RunningProcessor

func (*RunningProcessor) Apply added in v1.14.0

func (rp *RunningProcessor) Apply(in ...telegraf.Metric) []telegraf.Metric

func (*RunningProcessor) Init added in v1.14.0

func (r *RunningProcessor) Init() error

func (*RunningProcessor) Log added in v1.14.0

func (r *RunningProcessor) Log() telegraf.Logger

type RunningProcessors added in v1.14.0

type RunningProcessors []*RunningProcessor

func (RunningProcessors) Len added in v1.14.0

func (rp RunningProcessors) Len() int

func (RunningProcessors) Less added in v1.14.0

func (rp RunningProcessors) Less(i, j int) bool

func (RunningProcessors) Swap added in v1.14.0

func (rp RunningProcessors) Swap(i, j int)

type TagFilter

type TagFilter struct {
	Name   string
	Filter []string
	// contains filtered or unexported fields
}

TagFilter is the name of a tag, and the values on which to filter

Jump to

Keyboard shortcuts

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