Adding upstream version 1.34.4.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
e393c3af3f
commit
4978089aab
4963 changed files with 677545 additions and 0 deletions
40
parser.go
Normal file
40
parser.go
Normal file
|
@ -0,0 +1,40 @@
|
|||
package telegraf
|
||||
|
||||
// Parser is an interface defining functions that a parser plugin must satisfy.
|
||||
type Parser interface {
|
||||
// Parse takes a byte buffer separated by newlines
|
||||
// ie, `cpu.usage.idle 90\ncpu.usage.busy 10`
|
||||
// and parses it into telegraf metrics
|
||||
//
|
||||
// Must be thread-safe.
|
||||
Parse(buf []byte) ([]Metric, error)
|
||||
|
||||
// ParseLine takes a single string metric
|
||||
// ie, "cpu.usage.idle 90"
|
||||
// and parses it into a telegraf metric.
|
||||
//
|
||||
// Must be thread-safe.
|
||||
ParseLine(line string) (Metric, error)
|
||||
|
||||
// SetDefaultTags tells the parser to add all of the given tags
|
||||
// to each parsed metric.
|
||||
// NOTE: do _not_ modify the map after you've passed it here!!
|
||||
SetDefaultTags(tags map[string]string)
|
||||
}
|
||||
|
||||
// ParserFunc is a function to create a new instance of a parser
|
||||
type ParserFunc func() (Parser, error)
|
||||
|
||||
// ParserPlugin is an interface for plugins that are able to parse
|
||||
// arbitrary data formats.
|
||||
type ParserPlugin interface {
|
||||
// SetParser sets the parser function for the interface
|
||||
SetParser(parser Parser)
|
||||
}
|
||||
|
||||
// ParserFuncPlugin is an interface for plugins that are able to parse
|
||||
// arbitrary data formats.
|
||||
type ParserFuncPlugin interface {
|
||||
// GetParser returns a new parser.
|
||||
SetParserFunc(fn ParserFunc)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue