// Statistics returns statistics for periodic monitoring. func (b *balancewriter) Statistics(tags map[string]string) []models.Statistic { tags = models.Tags(tags).Merge(b.tags) statistics := make([]models.Statistic, len(b.stats)) for i := range b.stats { statistics[i] = models.Statistic{ Name: "subscriber", Tags: models.Tags(tags).Merge(map[string]string{"destination": b.stats[i].dest}), Values: map[string]interface{}{ statPointsWritten: atomic.LoadInt64(&b.stats[i].pointsWritten), statWriteFailures: atomic.LoadInt64(&b.stats[i].failures), }, } } return statistics }
// Returns byte array of a line protocol representation of the point func (p Point) Bytes(precision string) []byte { key := imodels.MakeKey([]byte(p.Name), imodels.Tags(p.Tags)) fields := imodels.Fields(p.Fields).MarshalBinary() kl := len(key) fl := len(fields) var bytes []byte if p.Time.IsZero() { bytes = make([]byte, fl+kl+1) copy(bytes, key) bytes[kl] = ' ' copy(bytes[kl+1:], fields) } else { timeStr := strconv.FormatInt(p.Time.UnixNano()/imodels.GetPrecisionMultiplier(precision), 10) tl := len(timeStr) bytes = make([]byte, fl+kl+tl+2) copy(bytes, key) bytes[kl] = ' ' copy(bytes[kl+1:], fields) bytes[kl+fl+1] = ' ' copy(bytes[kl+fl+2:], []byte(timeStr)) } return bytes }
// Statistics returns statistics for periodic monitoring. func (d *DatabaseIndex) Statistics(tags map[string]string) []models.Statistic { return []models.Statistic{{ Name: "database", Tags: models.Tags(map[string]string{"database": d.name}).Merge(tags), Values: map[string]interface{}{ statDatabaseSeries: atomic.LoadInt64(&d.stats.NumSeries), statDatabaseMeasurements: atomic.LoadInt64(&d.stats.NumMeasurements), }, }} }
// Statistics returns statistics for periodic monitoring. func (s *Shard) Statistics(tags map[string]string) []models.Statistic { tags = s.statTags.Merge(tags) statistics := []models.Statistic{{ Name: "shard", Tags: models.Tags(tags).Merge(map[string]string{"engine": s.options.EngineVersion}), Values: map[string]interface{}{ statWriteReq: atomic.LoadInt64(&s.stats.WriteReq), statSeriesCreate: atomic.LoadInt64(&s.stats.SeriesCreated), statFieldsCreate: atomic.LoadInt64(&s.stats.FieldsCreated), statWritePointsFail: atomic.LoadInt64(&s.stats.WritePointsFail), statWritePointsOK: atomic.LoadInt64(&s.stats.WritePointsOK), statWriteBytes: atomic.LoadInt64(&s.stats.BytesWritten), statDiskBytes: atomic.LoadInt64(&s.stats.DiskBytes), }, }} statistics = append(statistics, s.engine.Statistics(tags)...) return statistics }