Exemplo n.º 1
0
func (s *StatsNode) runStats([]byte) error {
	ticker := time.NewTicker(s.s.Interval)
	defer ticker.Stop()
	point := models.Point{
		Name: "stats",
		Tags: map[string]string{"node": s.en.Name()},
	}
	for {
		select {
		case <-s.closing:
			return nil
		case now := <-ticker.C:
			point.Time = now.UTC()
			stats := s.en.nodeStatsByGroup()
			for group, stat := range stats {
				point.Fields = stat.Fields
				point.Group = group
				point.Dimensions = stat.Dimensions
				point.Tags = stat.Tags
				for _, out := range s.outs {
					err := out.CollectPoint(point)
					if err != nil {
						return err
					}
				}
			}
		}
	}
}
Exemplo n.º 2
0
// Emit a set of stats data points.
func (s *StatsNode) emit(now time.Time) error {
	s.timer.Start()
	point := models.Point{
		Name: "stats",
		Tags: map[string]string{"node": s.en.Name()},
		Time: now.UTC(),
	}
	if s.s.AlignFlag {
		point.Time = point.Time.Round(s.s.Interval)
	}
	stats := s.en.nodeStatsByGroup()
	for group, stat := range stats {
		point.Fields = stat.Fields
		point.Group = group
		point.Dimensions = stat.Dimensions
		point.Tags = stat.Tags
		s.timer.Pause()
		for _, out := range s.outs {
			err := out.CollectPoint(point)
			if err != nil {
				return err
			}
		}
		s.timer.Resume()
	}
	s.timer.Stop()
	return nil
}
Exemplo n.º 3
0
func setGroupOnPoint(p models.Point, allDimensions bool, dimensions []string) models.Point {
	if allDimensions {
		dimensions = models.SortedKeys(p.Tags)
	}
	p.Group = models.TagsToGroupID(dimensions, p.Tags)
	p.Dimensions = dimensions
	return p
}
Exemplo n.º 4
0
func setGroupOnPoint(p models.Point, allDimensions bool, dimensions models.Dimensions) models.Point {
	if allDimensions {
		dimensions.TagNames = models.SortedKeys(p.Tags)
	}
	p.Group = models.ToGroupID(p.Name, p.Tags, dimensions)
	p.Dimensions = dimensions
	return p
}