Skip to content

Commit

Permalink
Small fixes for /active_series (#7106)
Browse files Browse the repository at this point in the history
* Do not forward `Accept-Encoding` header

* add parsed json to error

* fix queue dimension for active series queries

* log error

(cherry picked from commit bc4f4ee)
  • Loading branch information
flxbk authored and grafanabot committed Jan 11, 2024
1 parent 6ca4ee6 commit 70efe9e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions pkg/frontend/querymiddleware/shard_active_series.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"strings"

"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/grafana/dskit/tenant"
jsoniter "github.com/json-iterator/go"
"github.com/klauspost/compress/s2"
Expand Down Expand Up @@ -149,6 +150,7 @@ func buildShardedRequests(ctx context.Context, req *http.Request, numRequests in

reqs[i].Header.Set("Content-Type", "application/x-www-form-urlencoded")
reqs[i].Header.Del(totalShardsControlHeader)
reqs[i].Header.Del("Accept-Encoding")
reqs[i].Body = io.NopCloser(strings.NewReader(vals.Encode()))
}

Expand Down Expand Up @@ -261,9 +263,8 @@ func (s *shardActiveSeriesMiddleware) mergeResponses(ctx context.Context, respon
// If the field is neither data nor error, we skip it.
it.ReadAny()
}

if !foundDataField {
return errors.New("expected data field at top level")
return fmt.Errorf("expected data field at top level, found %s", it.CurrentBuffer())
}

if it.WhatIsNext() != jsoniter.ArrayValue {
Expand Down Expand Up @@ -350,6 +351,7 @@ func (s *shardActiveSeriesMiddleware) writeMergedResponse(ctx context.Context, c
stream.WriteArrayEnd()

if err := check(); err != nil {
level.Error(s.logger).Log("msg", "error merging partial responses", "err", err.Error())
span.LogFields(otlog.Error(err))
stream.WriteMore()
stream.WriteObjectField("status")
Expand Down
2 changes: 1 addition & 1 deletion pkg/frontend/v2/frontend_scheduler_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (a *frontendToSchedulerAdapter) extractAdditionalQueueDimensions(
return nil, err
}
return a.queryComponentQueueDimensionFromTimeParams(tenantIDs, start, end, now), nil
case querymiddleware.IsCardinalityQuery(httpRequest.URL.Path):
case querymiddleware.IsCardinalityQuery(httpRequest.URL.Path), querymiddleware.IsActiveSeriesQuery(httpRequest.URL.Path):
// cardinality only hits ingesters
return []string{ShouldQueryIngestersQueueDimension}, nil
default:
Expand Down

0 comments on commit 70efe9e

Please sign in to comment.