func (l *Librato) buildGauges(m telegraf.Metric) ([]*Gauge, error) { gauges := []*Gauge{} serializer := graphite.GraphiteSerializer{Template: l.Template} bucket := serializer.SerializeBucketName(m.Name(), m.Tags()) for fieldName, value := range m.Fields() { gauge := &Gauge{ Name: graphite.InsertField(bucket, fieldName), MeasureTime: m.Time().Unix(), } if !gauge.verifyValue(value) { continue } if err := gauge.setValue(value); err != nil { return gauges, fmt.Errorf("unable to extract value from Fields, %s\n", err.Error()) } if l.SourceTag != "" { if source, ok := m.Tags()[l.SourceTag]; ok { gauge.Source = source } else { return gauges, fmt.Errorf("undeterminable Source type from Field, %s\n", l.SourceTag) } } gauges = append(gauges, gauge) } if l.Debug { fmt.Printf("[DEBUG] Built gauges: %v\n", gauges) } return gauges, nil }
func (l *Librato) buildGaugeName(m telegraf.Metric, fieldName string) string { // Use the GraphiteSerializer graphiteSerializer := graphite.GraphiteSerializer{} serializedMetric := graphiteSerializer.SerializeBucketName(m, fieldName) // Deal with slash characters: return strings.Replace(serializedMetric, "/", "-", -1) }
func (l *Librato) buildGaugeName(m telegraf.Metric, fieldName string) string { // Use the GraphiteSerializer graphiteSerializer := graphite.GraphiteSerializer{} return graphiteSerializer.SerializeBucketName(m, fieldName) }