Ejemplo n.º 1
0
func addDimensionsFromName(m *metric.Metric, dimensions []string) {
	var dimension []string
	for i := 1; i < len(dimensions); i++ {
		dimension = strings.Split(dimensions[i], "=")
		m.AddDimension(dimension[0], dimension[1])
	}

}
Ejemplo n.º 2
0
// Collect reads metrics collected from Diamond collectors, converts
// them to fullerite's Metric type and publishes them to handlers.
func (d Diamond) Collect() {
	for line := range d.incoming {
		var metric metric.Metric
		if err := json.Unmarshal(line, &metric); err != nil {
			log.Error("Cannot unmarshal metric line from diamond:", line)
			continue
		}
		metric.AddDimension("diamond", "yes")
		d.Channel() <- metric
	}
}
Ejemplo n.º 3
0
func (d *Diamond) parseMetric(line []byte) (metric.Metric, bool) {
	var metric metric.Metric
	if err := json.Unmarshal(line, &metric); err != nil {
		d.log.Error("Cannot unmarshal metric line from diamond:", line)
		return metric, false
	}
	// All diamond metric_types are reported in uppercase, lets make them
	// fullerite compatible
	metric.MetricType = strings.ToLower(metric.MetricType)
	metric.AddDimension("diamond", "yes")
	return metric, true
}
Ejemplo n.º 4
0
// Collect reads metrics collected from Diamond collectors, converts
// them to fullerite's Metric type and publishes them to handlers.
func (d *Diamond) Collect() {
	if !d.serverStarted {
		d.serverStarted = true
		go d.collectDiamond()
	}

	for line := range d.incoming {
		var metric metric.Metric
		if err := json.Unmarshal(line, &metric); err != nil {
			d.log.Error("Cannot unmarshal metric line from diamond:", line)
			continue
		}
		metric.AddDimension("diamond", "yes")
		d.Channel() <- metric
	}
}