1
0
Fork 0

Adding upstream version 1.34.4.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-24 07:26:29 +02:00
parent e393c3af3f
commit 4978089aab
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
4963 changed files with 677545 additions and 0 deletions

40
parser.go Normal file
View 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)
}