From 4c74f8b1cf066aec6c050fb7ae54f1525f938941 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Fri, 10 May 2019 14:49:57 +0000 Subject: [PATCH] Add metrics for report size and count per tenant In a multitenant system it is useful to be able to drill into which tenants have the most or biggest reports. Signed-off-by: Bryan Boreham --- app/multitenant/aws_collector.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/multitenant/aws_collector.go b/app/multitenant/aws_collector.go index ab14816cb..6eaea8e1f 100644 --- a/app/multitenant/aws_collector.go +++ b/app/multitenant/aws_collector.go @@ -68,6 +68,16 @@ var ( Help: "Distribution of memcache report sizes", Buckets: prometheus.ExponentialBuckets(4096, 2.0, 10), }) + reportsPerUser = prometheus.NewCounterVec(prometheus.CounterOpts{ + Namespace: "scope", + Name: "reports_stored_total", + Help: "Total stored reports per user.", + }, []string{"user"}) + reportSizePerUser = prometheus.NewCounterVec(prometheus.CounterOpts{ + Namespace: "scope", + Name: "reports_bytes_total", + Help: "Total bytes stored in reports per user.", + }, []string{"user"}) natsRequests = prometheus.NewCounterVec(prometheus.CounterOpts{ Namespace: "scope", @@ -83,6 +93,8 @@ func init() { prometheus.MustRegister(inProcessCacheRequests) prometheus.MustRegister(inProcessCacheHits) prometheus.MustRegister(reportSizeHistogram) + prometheus.MustRegister(reportsPerUser) + prometheus.MustRegister(reportSizePerUser) prometheus.MustRegister(natsRequests) } @@ -434,6 +446,8 @@ func (c *awsCollector) Add(ctx context.Context, rep report.Report, buf []byte) e return err } reportSizeHistogram.Observe(float64(reportSize)) + reportSizePerUser.WithLabelValues(userid).Add(float64(reportSize)) + reportsPerUser.WithLabelValues(userid).Inc() // third, put it in memcache if c.cfg.MemcacheClient != nil {