2016-01-27 21:21:36 +00:00
|
|
|
package telegraf
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2016-08-30 17:09:48 +00:00
|
|
|
// ValueType is an enumeration of metric types that represent a simple value.
|
|
|
|
type ValueType int
|
|
|
|
|
|
|
|
// Possible values for the ValueType enum.
|
|
|
|
const (
|
|
|
|
_ ValueType = iota
|
|
|
|
Counter
|
|
|
|
Gauge
|
|
|
|
Untyped
|
2017-10-24 23:28:52 +00:00
|
|
|
Summary
|
|
|
|
Histogram
|
2016-08-30 17:09:48 +00:00
|
|
|
)
|
|
|
|
|
2020-04-03 17:11:41 +00:00
|
|
|
// Tag represents a single tag key and value.
|
2018-03-28 00:30:51 +00:00
|
|
|
type Tag struct {
|
|
|
|
Key string
|
|
|
|
Value string
|
|
|
|
}
|
|
|
|
|
2020-04-03 17:11:41 +00:00
|
|
|
// Field represents a single field key and value.
|
2018-03-28 00:30:51 +00:00
|
|
|
type Field struct {
|
|
|
|
Key string
|
|
|
|
Value interface{}
|
|
|
|
}
|
|
|
|
|
2020-04-03 17:11:41 +00:00
|
|
|
// Metric is the type of data that is processed by Telegraf. Input plugins,
|
|
|
|
// and to a lesser degree, Processor and Aggregator plugins create new Metrics
|
|
|
|
// and Output plugins write them.
|
2016-01-27 21:21:36 +00:00
|
|
|
type Metric interface {
|
2020-04-03 17:11:41 +00:00
|
|
|
// Name is the primary identifier for the Metric and corresponds to the
|
|
|
|
// measurement in the InfluxDB data model.
|
2018-03-28 00:30:51 +00:00
|
|
|
Name() string
|
2020-04-03 17:11:41 +00:00
|
|
|
|
|
|
|
// Tags returns the tags as a map. This method is deprecated, use TagList instead.
|
2018-03-28 00:30:51 +00:00
|
|
|
Tags() map[string]string
|
2020-04-03 17:11:41 +00:00
|
|
|
|
|
|
|
// TagList returns the tags as a slice ordered by the tag key in lexical
|
|
|
|
// bytewise ascending order. The returned value should not be modified,
|
|
|
|
// use the AddTag or RemoveTag methods instead.
|
2018-03-28 00:30:51 +00:00
|
|
|
TagList() []*Tag
|
2020-04-03 17:11:41 +00:00
|
|
|
|
|
|
|
// Fields returns the fields as a map. This method is deprecated, use FieldList instead.
|
2018-03-28 00:30:51 +00:00
|
|
|
Fields() map[string]interface{}
|
2020-04-03 17:11:41 +00:00
|
|
|
|
|
|
|
// FieldList returns the fields as a slice in an undefined order. The
|
|
|
|
// returned value should not be modified, use the AddField or RemoveField
|
|
|
|
// methods instead.
|
2018-03-28 00:30:51 +00:00
|
|
|
FieldList() []*Field
|
2020-04-03 17:11:41 +00:00
|
|
|
|
|
|
|
// Time returns the timestamp of the metric.
|
2018-03-28 00:30:51 +00:00
|
|
|
Time() time.Time
|
2020-04-03 17:11:41 +00:00
|
|
|
|
|
|
|
// Type returns a general type for the entire metric that describes how you
|
|
|
|
// might interprete, aggregate the values.
|
|
|
|
//
|
|
|
|
// This method may be removed in the future and its use is discouraged.
|
2018-03-28 00:30:51 +00:00
|
|
|
Type() ValueType
|
|
|
|
|
2020-04-03 17:11:41 +00:00
|
|
|
// SetName sets the metric name.
|
2018-03-28 00:30:51 +00:00
|
|
|
SetName(name string)
|
2020-04-03 17:11:41 +00:00
|
|
|
|
|
|
|
// AddPrefix adds a string to the front of the metric name. It is
|
|
|
|
// equivalent to m.SetName(prefix + m.Name()).
|
|
|
|
//
|
|
|
|
// This method is deprecated, use SetName instead.
|
2018-03-28 00:30:51 +00:00
|
|
|
AddPrefix(prefix string)
|
2020-04-03 17:11:41 +00:00
|
|
|
|
|
|
|
// AddSuffix appends a string to the back of the metric name. It is
|
|
|
|
// equivalent to m.SetName(m.Name() + suffix).
|
|
|
|
//
|
|
|
|
// This method is deprecated, use SetName instead.
|
2018-03-28 00:30:51 +00:00
|
|
|
AddSuffix(suffix string)
|
2016-01-27 21:21:36 +00:00
|
|
|
|
2020-04-03 17:11:41 +00:00
|
|
|
// GetTag returns the value of a tag and a boolean to indicate if it was set.
|
2018-03-28 00:30:51 +00:00
|
|
|
GetTag(key string) (string, bool)
|
2020-04-03 17:11:41 +00:00
|
|
|
|
|
|
|
// HasTag returns true if the tag is set on the Metric.
|
2016-11-22 12:51:57 +00:00
|
|
|
HasTag(key string) bool
|
2020-04-03 17:11:41 +00:00
|
|
|
|
|
|
|
// AddTag sets the tag on the Metric. If the Metric already has the tag
|
|
|
|
// set then the current value is replaced.
|
2016-11-22 12:51:57 +00:00
|
|
|
AddTag(key, value string)
|
2020-04-03 17:11:41 +00:00
|
|
|
|
|
|
|
// RemoveTag removes the tag if it is set.
|
2016-12-01 15:18:46 +00:00
|
|
|
RemoveTag(key string)
|
2016-01-27 21:21:36 +00:00
|
|
|
|
2020-04-03 17:11:41 +00:00
|
|
|
// GetField returns the value of a field and a boolean to indicate if it was set.
|
2018-03-28 00:30:51 +00:00
|
|
|
GetField(key string) (interface{}, bool)
|
2020-04-03 17:11:41 +00:00
|
|
|
|
|
|
|
// HasField returns true if the field is set on the Metric.
|
2016-11-22 12:51:57 +00:00
|
|
|
HasField(key string) bool
|
2020-04-03 17:11:41 +00:00
|
|
|
|
|
|
|
// AddField sets the field on the Metric. If the Metric already has the field
|
|
|
|
// set then the current value is replaced.
|
2016-11-22 12:51:57 +00:00
|
|
|
AddField(key string, value interface{})
|
2020-04-03 17:11:41 +00:00
|
|
|
|
|
|
|
// RemoveField removes the tag if it is set.
|
2018-03-28 00:30:51 +00:00
|
|
|
RemoveField(key string)
|
2016-08-30 17:09:48 +00:00
|
|
|
|
2020-04-03 17:11:41 +00:00
|
|
|
// SetTime sets the timestamp of the Metric.
|
2018-05-14 18:00:03 +00:00
|
|
|
SetTime(t time.Time)
|
|
|
|
|
2018-03-28 00:30:51 +00:00
|
|
|
// HashID returns an unique identifier for the series.
|
2016-09-08 14:22:10 +00:00
|
|
|
HashID() uint64
|
|
|
|
|
2018-03-28 00:30:51 +00:00
|
|
|
// Copy returns a deep copy of the Metric.
|
|
|
|
Copy() Metric
|
|
|
|
|
2018-11-05 21:34:28 +00:00
|
|
|
// Accept marks the metric as processed successfully and written to an
|
|
|
|
// output.
|
|
|
|
Accept()
|
|
|
|
|
|
|
|
// Reject marks the metric as processed unsuccessfully.
|
|
|
|
Reject()
|
|
|
|
|
|
|
|
// Drop marks the metric as processed successfully without being written
|
|
|
|
// to any output.
|
|
|
|
Drop()
|
|
|
|
|
2020-04-03 17:11:41 +00:00
|
|
|
// SetAggregate indicates the metric is an aggregated value.
|
|
|
|
//
|
|
|
|
// This method may be removed in the future and its use is discouraged.
|
2016-09-08 14:22:10 +00:00
|
|
|
SetAggregate(bool)
|
2020-04-03 17:11:41 +00:00
|
|
|
|
|
|
|
// IsAggregate returns true if the Metric is an aggregate.
|
|
|
|
//
|
|
|
|
// This method may be removed in the future and its use is discouraged.
|
2016-09-08 14:22:10 +00:00
|
|
|
IsAggregate() bool
|
2016-11-23 12:30:31 +00:00
|
|
|
}
|