Documentation
¶
Index ¶
- type Accumulator
- func (a *Accumulator) AddCounter(measurement string, fields map[string]interface{}, tags map[string]string, ...)
- func (a *Accumulator) AddError(err error)
- func (a *Accumulator) AddFields(measurement string, fields map[string]interface{}, tags map[string]string, ...)
- func (a *Accumulator) AddGauge(measurement string, fields map[string]interface{}, tags map[string]string, ...)
- func (a *Accumulator) AddHistogram(measurement string, fields map[string]interface{}, tags map[string]string, ...)
- func (a *Accumulator) AddMetric(telegraf.Metric)
- func (a *Accumulator) AddSummary(measurement string, fields map[string]interface{}, tags map[string]string, ...)
- func (a *Accumulator) PrepareGather()
- func (a *Accumulator) SetPrecision(time.Duration)
- func (a *Accumulator) WithTracking(maxTracked int) telegraf.TrackingAccumulator
- type GatherContext
- type Input
- type InputWithSecrets
- type Logger
- func (l Logger) Debug(args ...interface{})
- func (l Logger) Debugf(format string, args ...interface{})
- func (l Logger) Error(args ...interface{})
- func (l Logger) Errorf(format string, args ...interface{})
- func (l Logger) Info(args ...interface{})
- func (l Logger) Infof(format string, args ...interface{})
- func (l Logger) Warn(args ...interface{})
- func (l Logger) Warnf(format string, args ...interface{})
- type Measurement
- type RenameCallback
- type StoreAccumulator
- func (a *StoreAccumulator) AddCounter(measurement string, fields map[string]interface{}, tags map[string]string, ...)
- func (a *StoreAccumulator) AddError(err error)
- func (a *StoreAccumulator) AddFields(measurement string, fields map[string]interface{}, tags map[string]string, ...)
- func (a *StoreAccumulator) AddGauge(measurement string, fields map[string]interface{}, tags map[string]string, ...)
- func (a *StoreAccumulator) AddHistogram(measurement string, fields map[string]interface{}, tags map[string]string, ...)
- func (a *StoreAccumulator) AddMetric(telegraf.Metric)
- func (a *StoreAccumulator) AddSummary(measurement string, fields map[string]interface{}, tags map[string]string, ...)
- func (a *StoreAccumulator) Send(acc telegraf.Accumulator)
- func (a *StoreAccumulator) SetPrecision(time.Duration)
- func (a *StoreAccumulator) WithTracking(maxTracked int) telegraf.TrackingAccumulator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Accumulator ¶
type Accumulator struct { Accumulator telegraf.Accumulator // RenameGlobal apply global rename on all metrics from one batch. // It may: // * change the measurement name (prefix of metric name) // * alter tags // * completely drop this base (e.g. blocking a disk/network interface/...)) // You should return a modified version of originalContext to kept all non-modified field from originalContext. RenameGlobal func(gatherContext GatherContext) (result GatherContext, drop bool) // DifferentiatedMetrics is the list of metric counter to derive DifferentiatedMetrics []string // ShouldDifferentiateMetrics indicate if a metric should be derivated. It's an alternate way to DerivatedMetrics. // If both ShouldDifferentiateMetrics and DerivatedMetrics are set, only metrics not found in DerivatedMetrics are passed to ShouldDifferentiateMetrics ShouldDifferentiateMetrics func(currentContext GatherContext, metricName string) bool // TransformMetrics take a list of metrics and could change the name/value or even add/delete some points. // tags & measurement are given as indication and should not be mutated. TransformMetrics func(currentContext GatherContext, fields map[string]float64, originalFields map[string]interface{}) map[string]float64 // RenameMetrics apply a per-metric rename of metric name and measurement. tags can't be mutated RenameMetrics func(currentContext GatherContext, metricName string) (newMeasurement string, newMetricName string) RenameCallbacks []RenameCallback // contains filtered or unexported fields }
Accumulator implements telegraf.Accumulator with the capabilities to renames metrics, apply transformation (including derivation of value).
Transformations are implemented via a callback function The processing will be the following:
- PrepareGather must be called.
- The Gather() method should be called
- If TransformGlobal is set, it's applied. RenameTransform allow to rename measurement and alter tags. It could also completely drop a batch of metrics
- Any metrics matching DerivatedMetrics are derivated. Metric seen for the first time are dropped. Derivation is only applied to Counter values, that is something that only go upward. If value does downward, it's skipped.
- Then TransformMetrics is called on a float64 version of fields. It may apply per-metric transformation.
func (*Accumulator) AddCounter ¶
func (a *Accumulator) AddCounter(measurement string, fields map[string]interface{}, tags map[string]string, t ...time.Time)
AddCounter is the same as AddFields, but will add the metric as a "Counter" type.
func (*Accumulator) AddFields ¶
func (a *Accumulator) AddFields(measurement string, fields map[string]interface{}, tags map[string]string, t ...time.Time)
AddFields adds a metric to the accumulator with the given measurement name, fields, and tags (and timestamp). If a timestamp is not provided, then the accumulator sets it to "now".
func (*Accumulator) AddGauge ¶
func (a *Accumulator) AddGauge(measurement string, fields map[string]interface{}, tags map[string]string, t ...time.Time)
AddGauge is the same as AddFields, but will add the metric as a "Gauge" type.
func (*Accumulator) AddHistogram ¶
func (a *Accumulator) AddHistogram(measurement string, fields map[string]interface{}, tags map[string]string, t ...time.Time)
AddHistogram is the same as AddFields, but will add the metric as a "Histogram" type.
func (*Accumulator) AddMetric ¶
func (a *Accumulator) AddMetric(telegraf.Metric)
AddMetric adds an metric to the accumulator.
func (*Accumulator) AddSummary ¶
func (a *Accumulator) AddSummary(measurement string, fields map[string]interface{}, tags map[string]string, t ...time.Time)
AddSummary is the same as AddFields, but will add the metric as a "Summary" type.
func (*Accumulator) PrepareGather ¶
func (a *Accumulator) PrepareGather()
PrepareGather should be called before each gather. It's mainly useful for delta computation.
func (*Accumulator) SetPrecision ¶
func (a *Accumulator) SetPrecision(time.Duration)
SetPrecision takes two time.Duration objects. If the first is non-zero, it sets that as the precision. Otherwise, it takes the second argument as the order of time that the metrics should be rounded to, with the maximum being 1s.
func (*Accumulator) WithTracking ¶
func (a *Accumulator) WithTracking(maxTracked int) telegraf.TrackingAccumulator
WithTracking upgrades to a TrackingAccumulator with space for maxTracked metrics/batches.
type GatherContext ¶
type GatherContext struct { Measurement string OriginalMeasurement string OriginalTags map[string]string // OriginalTags had to be filled by RenameGlobal callback Tags map[string]string Annotations types.MetricAnnotations OriginalFields map[string]interface{} }
GatherContext is the couple Measurement and tags.
type Input ¶
type Input struct { telegraf.Input Accumulator Accumulator Name string // contains filtered or unexported fields }
Input is a generic input that use the modifying Accumulator defined in this package.
func (*Input) Gather ¶
func (i *Input) Gather(acc telegraf.Accumulator) error
Gather takes in an accumulator and adds the metrics that the Input gathers. This is called every "interval".
func (*Input) Init ¶
Init performs one time setup of the plugin and returns an error if the configuration is invalid.
func (*Input) SecretCount ¶
SecretCount allows getting the secret count of the underlying input.
type InputWithSecrets ¶
InputWithSecrets wraps an Input that has secrets.
func (InputWithSecrets) SecretCount ¶
func (si InputWithSecrets) SecretCount() int
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is an implementation of telegraf.Logger.
func (Logger) Debug ¶
func (l Logger) Debug(args ...interface{})
Debug logs a debug message, patterned after log.Print.
func (Logger) Error ¶
func (l Logger) Error(args ...interface{})
Error logs an error message, patterned after log.Print.
func (Logger) Info ¶
func (l Logger) Info(args ...interface{})
Info logs an information message, patterned after log.Print.
type Measurement ¶
type RenameCallback ¶
type RenameCallback func(labels map[string]string, annotations types.MetricAnnotations) (newLabels map[string]string, newAnnotations types.MetricAnnotations)
RenameCallback is a function which can mutate labels & annotations.
type StoreAccumulator ¶
type StoreAccumulator struct { Measurement []Measurement Errors []error }
StoreAccumulator store in memory all value pushed by AddFields, AddGauge... All type (fields, gauge, counter) are processed the same, and can't be distinguished.
func (*StoreAccumulator) AddCounter ¶
func (a *StoreAccumulator) AddCounter(measurement string, fields map[string]interface{}, tags map[string]string, t ...time.Time)
AddCounter is the same as AddFields, but will add the metric as a "Counter" type.
func (*StoreAccumulator) AddError ¶
func (a *StoreAccumulator) AddError(err error)
AddError reports an error.
func (*StoreAccumulator) AddFields ¶
func (a *StoreAccumulator) AddFields(measurement string, fields map[string]interface{}, tags map[string]string, t ...time.Time)
AddFields adds a metric to the accumulator with the given measurement name, fields, and tags (and timestamp). If a timestamp is not provided, then the accumulator sets it to "now".
func (*StoreAccumulator) AddGauge ¶
func (a *StoreAccumulator) AddGauge(measurement string, fields map[string]interface{}, tags map[string]string, t ...time.Time)
AddGauge is the same as AddFields, but will add the metric as a "Gauge" type.
func (*StoreAccumulator) AddHistogram ¶
func (a *StoreAccumulator) AddHistogram(measurement string, fields map[string]interface{}, tags map[string]string, t ...time.Time)
AddHistogram is the same as AddFields, but will add the metric as a "Histogram" type.
func (*StoreAccumulator) AddMetric ¶
func (a *StoreAccumulator) AddMetric(telegraf.Metric)
AddMetric adds an metric to the accumulator.
func (*StoreAccumulator) AddSummary ¶
func (a *StoreAccumulator) AddSummary(measurement string, fields map[string]interface{}, tags map[string]string, t ...time.Time)
AddSummary is the same as AddFields, but will add the metric as a "Summary" type.
func (*StoreAccumulator) Send ¶
func (a *StoreAccumulator) Send(acc telegraf.Accumulator)
Send forward all captured measurement using acc.AddFields. It also send errors using AddError.
func (*StoreAccumulator) SetPrecision ¶
func (a *StoreAccumulator) SetPrecision(time.Duration)
SetPrecision takes two time.Duration objects. If the first is non-zero, it sets that as the precision. Otherwise, it takes the second argument as the order of time that the metrics should be rounded to, with the maximum being 1s.
func (*StoreAccumulator) WithTracking ¶
func (a *StoreAccumulator) WithTracking(maxTracked int) telegraf.TrackingAccumulator
WithTracking upgrades to a TrackingAccumulator with space for maxTracked metrics/batches.