Skip to content

Commit

Permalink
add additional queue dimensions to query scheduler queue duration his…
Browse files Browse the repository at this point in the history
…togram (#6960)

* add additional queue dimensions to query scheduler queue duration histogram

* better logging of unsupported request type
  • Loading branch information
francoposa committed Dec 18, 2023
1 parent e434072 commit 5cc586d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion pkg/frontend/v2/frontend_scheduler_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package v2

import (
"context"
"fmt"
"time"

"github.com/go-kit/log"
Expand Down Expand Up @@ -89,7 +90,7 @@ func (a *frontendToSchedulerAdapter) extractAdditionalQueueDimensions(
return []string{ShouldQueryIngestersQueueDimension}, nil
default:
// no query time params to parse; cannot infer query component
level.Warn(a.log).Log("msg", "unsupported request type", "query", httpRequest)
level.Warn(a.log).Log("msg", "unsupported request type", "query", fmt.Sprintf("%+v", httpRequest))
return nil, nil
}
}
Expand Down
10 changes: 6 additions & 4 deletions pkg/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"flag"
"io"
"net/http"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -72,7 +73,7 @@ type Scheduler struct {
cancelledRequests *prometheus.CounterVec
connectedQuerierClients prometheus.GaugeFunc
connectedFrontendClients prometheus.GaugeFunc
queueDuration prometheus.Histogram
queueDuration *prometheus.HistogramVec
inflightRequests prometheus.Summary
}

Expand Down Expand Up @@ -145,11 +146,11 @@ func NewScheduler(cfg Config, limits Limits, log log.Logger, registerer promethe
})
s.requestQueue = queue.NewRequestQueue(s.log, cfg.MaxOutstandingPerTenant, cfg.AdditionalQueryQueueDimensionsEnabled, cfg.QuerierForgetDelay, s.queueLength, s.discardedRequests, enqueueDuration)

s.queueDuration = promauto.With(registerer).NewHistogram(prometheus.HistogramOpts{
s.queueDuration = promauto.With(registerer).NewHistogramVec(prometheus.HistogramOpts{
Name: "cortex_query_scheduler_queue_duration_seconds",
Help: "Time spent by requests in queue before getting picked up by a querier.",
Buckets: prometheus.DefBuckets,
})
}, []string{"user", "additional_queue_dimensions"})
s.connectedQuerierClients = promauto.With(registerer).NewGaugeFunc(prometheus.GaugeOpts{
Name: "cortex_query_scheduler_connected_querier_clients",
Help: "Number of querier worker clients currently connected to the query-scheduler.",
Expand Down Expand Up @@ -399,7 +400,8 @@ func (s *Scheduler) QuerierLoop(querier schedulerpb.SchedulerForQuerier_QuerierL
r := req.(*queue.SchedulerRequest)

queueTime := time.Since(r.EnqueueTime)
s.queueDuration.Observe(queueTime.Seconds())
additionalQueueDimensionLabels := strings.Join(r.AdditionalQueueDimensions, ":")
s.queueDuration.WithLabelValues(r.UserID, additionalQueueDimensionLabels).Observe(queueTime.Seconds())
r.QueueSpan.Finish()

/*
Expand Down

0 comments on commit 5cc586d

Please sign in to comment.