package graphite import ( "bufio" "bytes" "fmt" "io" "math" "sort" "strconv" "strings" "time" "github.com/influxdata/telegraf/plugins" "github.com/influxdata/telegraf/metric" ) // Minimum and maximum supported dates for timestamps. var ( MinDate = time.Date(1901, 12, 13, 0, 0, 0, 0, time.UTC) MaxDate = time.Date(2038, 1, 19, 0, 0, 0, 0, time.UTC) ) // Parser encapsulates a Graphite Parser. type GraphiteParser struct { Separator string Templates []string DefaultTags map[string]string matcher *matcher } func (p *GraphiteParser) SetDefaultTags(tags map[string]string) { p.DefaultTags = tags } func NewGraphiteParser( separator string, templates []string, defaultTags map[string]string, ) (*GraphiteParser, error) { var err error if separator == "" { separator = DefaultSeparator } p := &GraphiteParser{ Separator: separator, Templates: templates, } if defaultTags != nil { p.DefaultTags = defaultTags } matcher := newMatcher() p.matcher = matcher defaultTemplate, _ := NewTemplate("measurement*", nil, p.Separator) matcher.AddDefaultTemplate(defaultTemplate) tmplts := parsedTemplates{} for _, pattern := range p.Templates { tmplt := parsedTemplate{} tmplt.template = pattern // Format is [filter]