Parser is an interface defining functions that a parser plugin must satisfy.
| 4 | |
| 5 | // Parser is an interface defining functions that a parser plugin must satisfy. |
| 6 | type Parser interface { |
| 7 | // Parse takes a byte buffer separated by newlines |
| 8 | // ie, `cpu.usage.idle 90\ncpu.usage.busy 10` |
| 9 | // and parses it into telegraf metrics |
| 10 | // |
| 11 | // Must be thread-safe. |
| 12 | Parse(buf []byte) ([]Metric, error) |
| 13 | |
| 14 | // ParseLine takes a single string metric |
| 15 | // ie, "cpu.usage.idle 90" |
| 16 | // and parses it into a telegraf metric. |
| 17 | // |
| 18 | // Must be thread-safe. |
| 19 | ParseLine(line string) (Metric, error) |
| 20 | |
| 21 | // SetDefaultTags tells the parser to add all of the given tags |
| 22 | // to each parsed metric. |
| 23 | // NOTE: do _not_ modify the map after you've passed it here!! |
| 24 | SetDefaultTags(tags map[string]string) |
| 25 | } |
| 26 | |
| 27 | // ParserFunc is a function to create a new instance of a parser |
| 28 | type ParserFunc func() (Parser, error) |
no outgoing calls
no test coverage detected
searching dependent graphs…