Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add profiling labels to ingester's read path #8421

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
* [ENHANCEMENT] Query-frontend: log the start, end time and matchers for remote read requests to the query stats logs. #8326 #8370 #8373
* [ENHANCEMENT] Query-frontend: be able to block remote read queries via the per tenant runtime override `blocked_queries`. #8372 #8415
* [ENHANCEMENT] Query-frontend: added `remote_read` to `op` supported label values for the `cortex_query_frontend_queries_total` metric. #8412
* [ENHANCEMENT] Ingester: read path requests now add userID and matchers labels to profiles. #8421
* [BUGFIX] Distributor: prometheus retry on 5xx and 429 errors, while otlp collector only retry on 429, 502, 503 and 504, mapping other 5xx errors to the retryable ones in otlp endpoint. #8324 #8339
* [BUGFIX] Distributor: make OTLP endpoint return marshalled proto bytes as response body for 4xx/5xx errors. #8227
* [BUGFIX] Rules: improve error handling when querier is local to the ruler. #7567
Expand Down
11 changes: 10 additions & 1 deletion pkg/ingester/active_series.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package ingester
import (
"context"
"fmt"
"runtime/pprof"

"github.com/go-kit/log/level"
"github.com/grafana/dskit/tenant"
Expand All @@ -17,6 +18,7 @@ import (
"github.com/grafana/mimir/pkg/ingester/client"
"github.com/grafana/mimir/pkg/mimirpb"
"github.com/grafana/mimir/pkg/storage/sharding"
"github.com/grafana/mimir/pkg/util"
"github.com/grafana/mimir/pkg/util/spanlogger"
"github.com/grafana/mimir/pkg/util/tracing"
)
Expand Down Expand Up @@ -47,6 +49,14 @@ func (i *Ingester) ActiveSeries(request *client.ActiveSeriesRequest, stream clie
return fmt.Errorf("error parsing label matchers: %w", err)
}

isNativeHistogram := request.GetType() == client.NATIVE_HISTOGRAM_SERIES
pprof.Do(ctx, pprof.Labels("method", "Ingester.ActiveSeries", "userID", userID, "matchers", util.MatchersStringer(matchers).String()), func(ctx context.Context) {
err = i.activeSeries(ctx, userID, matchers, isNativeHistogram, stream)
})
return err
}

func (i *Ingester) activeSeries(ctx context.Context, userID string, matchers []*labels.Matcher, isNativeHistogram bool, stream client.Ingester_ActiveSeriesServer) (err error) {
// Enforce read consistency before getting TSDB (covers the case the tenant's data has not been ingested
// in this ingester yet, but there's some to ingest in the backlog).
if err := i.enforceReadConsistency(ctx, userID); err != nil {
Expand All @@ -64,7 +74,6 @@ func (i *Ingester) ActiveSeries(request *client.ActiveSeriesRequest, stream clie
return fmt.Errorf("error getting index: %w", err)
}

isNativeHistogram := request.GetType() == client.NATIVE_HISTOGRAM_SERIES
postings, err := getPostings(ctx, db, idx, matchers, isNativeHistogram)
if err != nil {
return fmt.Errorf("error listing active series: %w", err)
Expand Down
Loading
Loading