1package telegraf
2
3import (
4	"time"
5)
6
7// ValueType is an enumeration of metric types that represent a simple value.
8type ValueType int
9
10// Possible values for the ValueType enum.
11const (
12	_ ValueType = iota
13	Counter
14	Gauge
15	Untyped
16	Summary
17	Histogram
18)
19
20// Tag represents a single tag key and value.
21type Tag struct {
22	Key   string
23	Value string
24}
25
26// Field represents a single field key and value.
27type Field struct {
28	Key   string
29	Value interface{}
30}
31
32// Metric is the type of data that is processed by Telegraf.  Input plugins,
33// and to a lesser degree, Processor and Aggregator plugins create new Metrics
34// and Output plugins write them.
35type Metric interface {
36	// Name is the primary identifier for the Metric and corresponds to the
37	// measurement in the InfluxDB data model.
38	Name() string
39
40	// Tags returns the tags as a map.  This method is deprecated, use TagList instead.
41	Tags() map[string]string
42
43	// TagList returns the tags as a slice ordered by the tag key in lexical
44	// bytewise ascending order.  The returned value should not be modified,
45	// use the AddTag or RemoveTag methods instead.
46	TagList() []*Tag
47
48	// Fields returns the fields as a map.  This method is deprecated, use FieldList instead.
49	Fields() map[string]interface{}
50
51	// FieldList returns the fields as a slice in an undefined order.  The
52	// returned value should not be modified, use the AddField or RemoveField
53	// methods instead.
54	FieldList() []*Field
55
56	// Time returns the timestamp of the metric.
57	Time() time.Time
58
59	// Type returns a general type for the entire metric that describes how you
60	// might interpret, aggregate the values.
61	//
62	// This method may be removed in the future and its use is discouraged.
63	Type() ValueType
64
65	// SetName sets the metric name.
66	SetName(name string)
67
68	// AddPrefix adds a string to the front of the metric name.  It is
69	// equivalent to m.SetName(prefix + m.Name()).
70	//
71	// This method is deprecated, use SetName instead.
72	AddPrefix(prefix string)
73
74	// AddSuffix appends a string to the back of the metric name.  It is
75	// equivalent to m.SetName(m.Name() + suffix).
76	//
77	// This method is deprecated, use SetName instead.
78	AddSuffix(suffix string)
79
80	// GetTag returns the value of a tag and a boolean to indicate if it was set.
81	GetTag(key string) (string, bool)
82
83	// HasTag returns true if the tag is set on the Metric.
84	HasTag(key string) bool
85
86	// AddTag sets the tag on the Metric.  If the Metric already has the tag
87	// set then the current value is replaced.
88	AddTag(key, value string)
89
90	// RemoveTag removes the tag if it is set.
91	RemoveTag(key string)
92
93	// GetField returns the value of a field and a boolean to indicate if it was set.
94	GetField(key string) (interface{}, bool)
95
96	// HasField returns true if the field is set on the Metric.
97	HasField(key string) bool
98
99	// AddField sets the field on the Metric.  If the Metric already has the field
100	// set then the current value is replaced.
101	AddField(key string, value interface{})
102
103	// RemoveField removes the tag if it is set.
104	RemoveField(key string)
105
106	// SetTime sets the timestamp of the Metric.
107	SetTime(t time.Time)
108
109	// HashID returns an unique identifier for the series.
110	HashID() uint64
111
112	// Copy returns a deep copy of the Metric.
113	Copy() Metric
114
115	// Accept marks the metric as processed successfully and written to an
116	// output.
117	Accept()
118
119	// Reject marks the metric as processed unsuccessfully.
120	Reject()
121
122	// Drop marks the metric as processed successfully without being written
123	// to any output.
124	Drop()
125
126	// SetAggregate indicates the metric is an aggregated value.
127	//
128	// This method may be removed in the future and its use is discouraged.
129	SetAggregate(bool)
130
131	// IsAggregate returns true if the Metric is an aggregate.
132	//
133	// This method may be removed in the future and its use is discouraged.
134	IsAggregate() bool
135}
136