From 0776c1c49ca4f9cb41040c68c764987cde175e4a Mon Sep 17 00:00:00 2001 From: Patrick Schork <354473+pschork@users.noreply.github.com> Date: Tue, 25 Jun 2024 17:35:15 -0700 Subject: [PATCH] Use auto rate interval for blob thoughput metrics DA internal dashboard blob throughput does not match blob explorer throughput graphs because dataapi query uses 120s rate interval and DA dashboard uses auto $__rateInterval. This change converts dataAPI metrics to use the auto $__rateInterval. See https://grafana.com/blog/2020/09/28/new-in-grafana-7.2-__rate_interval-for-prometheus-rate-queries-that-just-work/ --- disperser/dataapi/metrics_handlers.go | 2 +- disperser/dataapi/prometheus_client.go | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/disperser/dataapi/metrics_handlers.go b/disperser/dataapi/metrics_handlers.go index 5f18ba4223..66444d1000 100644 --- a/disperser/dataapi/metrics_handlers.go +++ b/disperser/dataapi/metrics_handlers.go @@ -79,7 +79,7 @@ func (s *server) getMetric(ctx context.Context, startTime int64, endTime int64) } func (s *server) getThroughput(ctx context.Context, start int64, end int64) ([]*Throughput, error) { - result, err := s.promClient.QueryDisperserAvgThroughputBlobSizeBytes(ctx, time.Unix(start, 0), time.Unix(end, 0), avgThroughputWindowSize) + result, err := s.promClient.QueryDisperserAvgThroughputBlobSizeBytes(ctx, time.Unix(start, 0), time.Unix(end, 0)) if err != nil { return nil, err } diff --git a/disperser/dataapi/prometheus_client.go b/disperser/dataapi/prometheus_client.go index 0d9db872fe..f08f22e231 100644 --- a/disperser/dataapi/prometheus_client.go +++ b/disperser/dataapi/prometheus_client.go @@ -11,14 +11,13 @@ import ( const ( // maxNumOfDataPoints is the maximum number of data points that can be queried from Prometheus based on latency that this API can provide - maxNumOfDataPoints = 3500 - throughputRateWindowInSec = 60 + maxNumOfDataPoints = 3500 ) type ( PrometheusClient interface { QueryDisperserBlobSizeBytesPerSecond(ctx context.Context, start time.Time, end time.Time) (*PrometheusResult, error) - QueryDisperserAvgThroughputBlobSizeBytes(ctx context.Context, start time.Time, end time.Time, windowSizeInSec uint8) (*PrometheusResult, error) + QueryDisperserAvgThroughputBlobSizeBytes(ctx context.Context, start time.Time, end time.Time) (*PrometheusResult, error) } PrometheusResultValues struct { @@ -47,12 +46,8 @@ func (pc *prometheusClient) QueryDisperserBlobSizeBytesPerSecond(ctx context.Con return pc.queryRange(ctx, query, start, end) } -func (pc *prometheusClient) QueryDisperserAvgThroughputBlobSizeBytes(ctx context.Context, start time.Time, end time.Time, windowSizeInSec uint8) (*PrometheusResult, error) { - if windowSizeInSec < throughputRateWindowInSec { - windowSizeInSec = throughputRateWindowInSec - } - - query := fmt.Sprintf("sum by (job) (rate(eigenda_batcher_blobs_total{state=\"confirmed\",data=\"size\",cluster=\"%s\"}[%ds]))", pc.cluster, windowSizeInSec) +func (pc *prometheusClient) QueryDisperserAvgThroughputBlobSizeBytes(ctx context.Context, start time.Time, end time.Time) (*PrometheusResult, error) { + query := fmt.Sprintf("sum by (job) (rate(eigenda_batcher_blobs_total{state=\"confirmed\",data=\"size\",cluster=\"%s\"}[$$__rate_interval]))", pc.cluster) return pc.queryRange(ctx, query, start, end) }