Add a metric to track total bytes sent per remote write queue. (#6344)

Signed-off-by: Callum Styan <callumstyan@gmail.com>
This commit is contained in:
Callum Styan 2019-11-25 12:25:18 -08:00 committed by Chris Marchbanks
parent 4be90b201e
commit c2cb1e4103

View File

@ -170,6 +170,15 @@ var (
}, },
[]string{queue}, []string{queue},
) )
bytesSent = promauto.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "sent_bytes_total",
Help: "The total number of bytes sent by the queue.",
},
[]string{queue},
)
) )
// StorageClient defines an interface for sending a batch of samples to an // StorageClient defines an interface for sending a batch of samples to an
@ -224,6 +233,7 @@ type QueueManager struct {
maxNumShards prometheus.Gauge maxNumShards prometheus.Gauge
minNumShards prometheus.Gauge minNumShards prometheus.Gauge
desiredNumShards prometheus.Gauge desiredNumShards prometheus.Gauge
bytesSent prometheus.Counter
} }
// NewQueueManager builds a new QueueManager. // NewQueueManager builds a new QueueManager.
@ -331,6 +341,7 @@ func (t *QueueManager) Start() {
t.maxNumShards = maxNumShards.WithLabelValues(name) t.maxNumShards = maxNumShards.WithLabelValues(name)
t.minNumShards = minNumShards.WithLabelValues(name) t.minNumShards = minNumShards.WithLabelValues(name)
t.desiredNumShards = desiredNumShards.WithLabelValues(name) t.desiredNumShards = desiredNumShards.WithLabelValues(name)
t.bytesSent = bytesSent.WithLabelValues(name)
// Initialise some metrics. // Initialise some metrics.
t.shardCapacity.Set(float64(t.cfg.Capacity)) t.shardCapacity.Set(float64(t.cfg.Capacity))
@ -827,6 +838,7 @@ func (s *shards) sendSamplesWithBackoff(ctx context.Context, samples []prompb.Ti
if err == nil { if err == nil {
s.qm.succeededSamplesTotal.Add(float64(len(samples))) s.qm.succeededSamplesTotal.Add(float64(len(samples)))
s.qm.bytesSent.Add(float64(len(req)))
s.qm.highestSentTimestampMetric.Set(float64(highest / 1000)) s.qm.highestSentTimestampMetric.Set(float64(highest / 1000))
atomic.StoreInt64(&s.qm.lastSendTimestamp, time.Now().Unix()) atomic.StoreInt64(&s.qm.lastSendTimestamp, time.Now().Unix())
return nil return nil