Ejemplo n.º 1
0
func BuildTags(t *testing.T) {
	testMetric := testutil.TestMetric(0.0, "test1")
	graphiteSerializer := graphite.GraphiteSerializer{}
	tags, err := graphiteSerializer.Serialize(testMetric)
	fmt.Printf("Tags: %v", tags)
	require.NoError(t, err)
}
Ejemplo n.º 2
0
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
}
Ejemplo n.º 3
0
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)
}
Ejemplo n.º 4
0
func (l *Librato) buildGaugeName(m telegraf.Metric, fieldName string) string {
	// Use the GraphiteSerializer
	graphiteSerializer := graphite.GraphiteSerializer{}
	return graphiteSerializer.SerializeBucketName(m, fieldName)
}