Skip to content

Commit

Permalink
Revert "Query: add query metrics to calls going through the Store API (
Browse files Browse the repository at this point in the history
…thanos-io#5741)"

This reverts commit eec4fd0.

Signed-off-by: utukj <utukphd@gmail.com>
  • Loading branch information
utukJ committed Oct 18, 2022
1 parent f01954d commit 3d6dd07
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 478 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
- [#5734](https://github.com/thanos-io/thanos/pull/5734) Store: Support disable block viewer UI.
- [#5411](https://github.com/thanos-io/thanos/pull/5411) Tracing: Add OpenTelemetry Protocol exporter.
- [#5779](https://github.com/thanos-io/thanos/pull/5779) Objstore: Support specifying S3 storage class.
- [#5741](https://github.com/thanos-io/thanos/pull/5741) Query: add metrics on how much data is being selected by downstream Store APIs.
- [#5673](https://github.com/thanos-io/thanos/pull/5673) Receive: Reload tenant limit configuration on file change.

### Changed
Expand Down
19 changes: 1 addition & 18 deletions cmd/thanos/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import (
"github.com/prometheus/prometheus/discovery/targetgroup"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/promql"
"google.golang.org/grpc"

v1 "github.com/prometheus/prometheus/web/api/v1"
"github.com/thanos-community/promql-engine/engine"
apiv1 "github.com/thanos-io/thanos/pkg/api/query"
Expand Down Expand Up @@ -56,6 +54,7 @@ import (
"github.com/thanos-io/thanos/pkg/targets"
"github.com/thanos-io/thanos/pkg/tls"
"github.com/thanos-io/thanos/pkg/ui"
"google.golang.org/grpc"
)

const (
Expand Down Expand Up @@ -206,10 +205,6 @@ func registerQuery(app *extkingpin.App) {
alertQueryURL := cmd.Flag("alert.query-url", "The external Thanos Query URL that would be set in all alerts 'Source' field.").String()
grpcProxyStrategy := cmd.Flag("grpc.proxy-strategy", "Strategy to use when proxying Series requests to leaf nodes. Hidden and only used for testing, will be removed after lazy becomes the default.").Default(string(store.EagerRetrieval)).Hidden().Enum(string(store.EagerRetrieval), string(store.LazyRetrieval))

queryTelemetryDurationQuantiles := cmd.Flag("query.telemetry.request-duration-seconds-quantiles", "The quantiles for exporting metrics about the request duration quantiles.").Default("0.1", "0.25", "0.75", "1.25", "1.75", "2.5", "3", "5", "10").Float64List()
queryTelemetrySamplesQuantiles := cmd.Flag("query.telemetry.request-samples-quantiles", "The quantiles for exporting metrics about the samples count quantiles.").Default("100", "1000", "10000", "100000", "1000000").Int64List()
queryTelemetrySeriesQuantiles := cmd.Flag("query.telemetry.request-series-seconds-quantiles", "The quantiles for exporting metrics about the series count quantiles.").Default("10", "100", "1000", "10000", "100000").Int64List()

cmd.Setup(func(g *run.Group, logger log.Logger, reg *prometheus.Registry, tracer opentracing.Tracer, _ <-chan struct{}, _ bool) error {
selectorLset, err := parseFlagLabels(*selectorLabels)
if err != nil {
Expand Down Expand Up @@ -322,9 +317,6 @@ func registerQuery(app *extkingpin.App) {
*alertQueryURL,
*grpcProxyStrategy,
component.Query,
*queryTelemetryDurationQuantiles,
*queryTelemetrySamplesQuantiles,
*queryTelemetrySeriesQuantiles,
promqlEngineType(*promqlEngine),
)
})
Expand Down Expand Up @@ -398,9 +390,6 @@ func runQuery(
alertQueryURL string,
grpcProxyStrategy string,
comp component.Component,
queryTelemetryDurationQuantiles []float64,
queryTelemetrySamplesQuantiles []int64,
queryTelemetrySeriesQuantiles []int64,
promqlEngine promqlEngineType,
) error {
if alertQueryURL == "" {
Expand Down Expand Up @@ -705,12 +694,6 @@ func runQuery(
extprom.WrapRegistererWithPrefix("thanos_query_concurrent_", reg),
maxConcurrentQueries,
),
store.NewSeriesStatsAggregator(
reg,
queryTelemetryDurationQuantiles,
queryTelemetrySamplesQuantiles,
queryTelemetrySeriesQuantiles,
),
reg,
)

Expand Down
19 changes: 0 additions & 19 deletions docs/components/query.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,15 +381,6 @@ Flags:
be able to query without deduplication using
'dedup=false' parameter. Data includes time
series, recording rules, and alerting rules.
--query.telemetry.request-duration-seconds-quantiles=0.1... ...
The quantiles for exporting metrics about the
request duration quantiles.
--query.telemetry.request-samples-quantiles=100... ...
The quantiles for exporting metrics about the
samples count quantiles.
--query.telemetry.request-series-seconds-quantiles=10... ...
The quantiles for exporting metrics about the
series count quantiles.
--query.timeout=2m Maximum time to process query by query node.
--request.logging-config=<content>
Alternative to 'request.logging-config-file'
Expand Down Expand Up @@ -472,13 +463,3 @@ Flags:
of Prometheus.
```

## Exported metrics

Thanos Query also exports metrics about its own performance. You can find a list with these metrics below.

**Disclaimer**: this list is incomplete. The remaining metrics will be added over time.

| Name | Type | Labels | Description |
|-----------------------------------------|-----------|-----------------------|-------------------------------------------------------------------------------------------------------------------|
| thanos_store_api_query_duration_seconds | Histogram | samples_le, series_le | Duration of the Thanos Store API select phase for a query according to the amount of samples and series selected. |
2 changes: 0 additions & 2 deletions pkg/api/query/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ func (g *GRPCAPI) Query(request *querypb.QueryRequest, server querypb.Query_Quer
request.EnableQueryPushdown,
false,
request.ShardInfo,
query.NoopSeriesStatsReporter,
)
qry, err := g.queryEngine.NewInstantQuery(queryable, &promql.QueryOpts{LookbackDelta: lookbackDelta}, request.Query, ts)
if err != nil {
Expand Down Expand Up @@ -169,7 +168,6 @@ func (g *GRPCAPI) QueryRange(request *querypb.QueryRangeRequest, srv querypb.Que
request.EnableQueryPushdown,
false,
request.ShardInfo,
query.NoopSeriesStatsReporter,
)

startTime := time.Unix(request.StartTimeSeconds, 0)
Expand Down
99 changes: 11 additions & 88 deletions pkg/api/query/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ import (
"github.com/prometheus/prometheus/promql"
"github.com/prometheus/prometheus/promql/parser"
"github.com/prometheus/prometheus/storage"
"github.com/prometheus/prometheus/util/stats"
v1 "github.com/prometheus/prometheus/web/api/v1"

"github.com/prometheus/prometheus/util/stats"

"github.com/thanos-io/thanos/pkg/api"
"github.com/thanos-io/thanos/pkg/exemplars"
"github.com/thanos-io/thanos/pkg/exemplars/exemplarspb"
Expand All @@ -55,7 +57,6 @@ import (
"github.com/thanos-io/thanos/pkg/rules"
"github.com/thanos-io/thanos/pkg/rules/rulespb"
"github.com/thanos-io/thanos/pkg/runutil"
"github.com/thanos-io/thanos/pkg/store"
"github.com/thanos-io/thanos/pkg/store/storepb"
"github.com/thanos-io/thanos/pkg/targets"
"github.com/thanos-io/thanos/pkg/targets/targetspb"
Expand Down Expand Up @@ -106,13 +107,6 @@ type QueryAPI struct {
defaultMetadataTimeRange time.Duration

queryRangeHist prometheus.Histogram

seriesStatsAggregator seriesQueryPerformanceMetricsAggregator
}

type seriesQueryPerformanceMetricsAggregator interface {
Aggregate(seriesStats storepb.SeriesStatsCounter)
Observe(duration float64)
}

// NewQueryAPI returns an initialized QueryAPI type.
Expand Down Expand Up @@ -140,12 +134,8 @@ func NewQueryAPI(
defaultMetadataTimeRange time.Duration,
disableCORS bool,
gate gate.Gate,
statsAggregator seriesQueryPerformanceMetricsAggregator,
reg *prometheus.Registry,
) *QueryAPI {
if statsAggregator == nil {
statsAggregator = &store.NoopSeriesStatsAggregator{}
}
return &QueryAPI{
baseAPI: api.NewBaseAPI(logger, disableCORS, flagsMap),
logger: logger,
Expand All @@ -170,7 +160,6 @@ func NewQueryAPI(
defaultInstantQueryMaxSourceResolution: defaultInstantQueryMaxSourceResolution,
defaultMetadataTimeRange: defaultMetadataTimeRange,
disableCORS: disableCORS,
seriesStatsAggregator: statsAggregator,

queryRangeHist: promauto.With(reg).NewHistogram(prometheus.HistogramOpts{
Name: "thanos_query_range_requested_timespan_duration_seconds",
Expand Down Expand Up @@ -407,24 +396,7 @@ func (qapi *QueryAPI) query(r *http.Request) (interface{}, []error, *api.ApiErro
span, ctx := tracing.StartSpan(ctx, "promql_instant_query")
defer span.Finish()

var seriesStats []storepb.SeriesStatsCounter
qry, err := qapi.queryEngine.NewInstantQuery(
qapi.queryableCreate(
enableDedup,
replicaLabels,
storeDebugMatchers,
maxSourceResolution,
enablePartialResponse,
qapi.enableQueryPushdown,
false,
shardInfo,
query.NewAggregateStatsReporter(&seriesStats),
),
&promql.QueryOpts{LookbackDelta: lookbackDelta},
r.FormValue("query"),
ts,
)

qry, err := qapi.queryEngine.NewInstantQuery(qapi.queryableCreate(enableDedup, replicaLabels, storeDebugMatchers, maxSourceResolution, enablePartialResponse, qapi.enableQueryPushdown, false, shardInfo), &promql.QueryOpts{LookbackDelta: lookbackDelta}, r.FormValue("query"), ts)
if err != nil {
return nil, nil, &api.ApiError{Typ: api.ErrorBadData, Err: err}, func() {}
}
Expand All @@ -437,7 +409,6 @@ func (qapi *QueryAPI) query(r *http.Request) (interface{}, []error, *api.ApiErro
}
defer qapi.gate.Done()

beforeRange := time.Now()
res := qry.Exec(ctx)
if res.Err != nil {
switch res.Err.(type) {
Expand All @@ -450,10 +421,6 @@ func (qapi *QueryAPI) query(r *http.Request) (interface{}, []error, *api.ApiErro
}
return nil, nil, &api.ApiError{Typ: api.ErrorExec, Err: res.Err}, qry.Close
}
for i := range seriesStats {
qapi.seriesStatsAggregator.Aggregate(seriesStats[i])
}
qapi.seriesStatsAggregator.Observe(time.Since(beforeRange).Seconds())

// Optional stats field in response if parameter "stats" is not empty.
var qs stats.QueryStats
Expand Down Expand Up @@ -558,19 +525,8 @@ func (qapi *QueryAPI) queryRange(r *http.Request) (interface{}, []error, *api.Ap
span, ctx := tracing.StartSpan(ctx, "promql_range_query")
defer span.Finish()

var seriesStats []storepb.SeriesStatsCounter
qry, err := qapi.queryEngine.NewRangeQuery(
qapi.queryableCreate(
enableDedup,
replicaLabels,
storeDebugMatchers,
maxSourceResolution,
enablePartialResponse,
qapi.enableQueryPushdown,
false,
shardInfo,
query.NewAggregateStatsReporter(&seriesStats),
),
qapi.queryableCreate(enableDedup, replicaLabels, storeDebugMatchers, maxSourceResolution, enablePartialResponse, qapi.enableQueryPushdown, false, shardInfo),
&promql.QueryOpts{LookbackDelta: lookbackDelta},
r.FormValue("query"),
start,
Expand All @@ -589,7 +545,6 @@ func (qapi *QueryAPI) queryRange(r *http.Request) (interface{}, []error, *api.Ap
}
defer qapi.gate.Done()

beforeRange := time.Now()
res := qry.Exec(ctx)
if res.Err != nil {
switch res.Err.(type) {
Expand All @@ -600,10 +555,6 @@ func (qapi *QueryAPI) queryRange(r *http.Request) (interface{}, []error, *api.Ap
}
return nil, nil, &api.ApiError{Typ: api.ErrorExec, Err: res.Err}, qry.Close
}
for i := range seriesStats {
qapi.seriesStatsAggregator.Aggregate(seriesStats[i])
}
qapi.seriesStatsAggregator.Observe(time.Since(beforeRange).Seconds())

// Optional stats field in response if parameter "stats" is not empty.
var qs stats.QueryStats
Expand Down Expand Up @@ -649,17 +600,8 @@ func (qapi *QueryAPI) labelValues(r *http.Request) (interface{}, []error, *api.A
matcherSets = append(matcherSets, matchers)
}

q, err := qapi.queryableCreate(
true,
nil,
storeDebugMatchers,
0,
enablePartialResponse,
qapi.enableQueryPushdown,
true,
nil,
query.NoopSeriesStatsReporter,
).Querier(ctx, timestamp.FromTime(start), timestamp.FromTime(end))
q, err := qapi.queryableCreate(true, nil, storeDebugMatchers, 0, enablePartialResponse, qapi.enableQueryPushdown, true, nil).
Querier(ctx, timestamp.FromTime(start), timestamp.FromTime(end))
if err != nil {
return nil, nil, &api.ApiError{Typ: api.ErrorExec, Err: err}, func() {}
}
Expand Down Expand Up @@ -745,18 +687,8 @@ func (qapi *QueryAPI) series(r *http.Request) (interface{}, []error, *api.ApiErr
return nil, nil, apiErr, func() {}
}

q, err := qapi.queryableCreate(
enableDedup,
replicaLabels,
storeDebugMatchers,
math.MaxInt64,
enablePartialResponse,
qapi.enableQueryPushdown,
true,
nil,
query.NoopSeriesStatsReporter,
).Querier(r.Context(), timestamp.FromTime(start), timestamp.FromTime(end))

q, err := qapi.queryableCreate(enableDedup, replicaLabels, storeDebugMatchers, math.MaxInt64, enablePartialResponse, qapi.enableQueryPushdown, true, nil).
Querier(r.Context(), timestamp.FromTime(start), timestamp.FromTime(end))
if err != nil {
return nil, nil, &api.ApiError{Typ: api.ErrorExec, Err: err}, func() {}
}
Expand Down Expand Up @@ -805,17 +737,8 @@ func (qapi *QueryAPI) labelNames(r *http.Request) (interface{}, []error, *api.Ap
matcherSets = append(matcherSets, matchers)
}

q, err := qapi.queryableCreate(
true,
nil,
storeDebugMatchers,
0,
enablePartialResponse,
qapi.enableQueryPushdown,
true,
nil,
query.NoopSeriesStatsReporter,
).Querier(r.Context(), timestamp.FromTime(start), timestamp.FromTime(end))
q, err := qapi.queryableCreate(true, nil, storeDebugMatchers, 0, enablePartialResponse, qapi.enableQueryPushdown, true, nil).
Querier(r.Context(), timestamp.FromTime(start), timestamp.FromTime(end))
if err != nil {
return nil, nil, &api.ApiError{Typ: api.ErrorExec, Err: err}, func() {}
}
Expand Down
6 changes: 2 additions & 4 deletions pkg/api/query/v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ import (
"github.com/prometheus/prometheus/tsdb/tsdbutil"
promgate "github.com/prometheus/prometheus/util/gate"
"github.com/prometheus/prometheus/util/stats"
baseAPI "github.com/thanos-io/thanos/pkg/api"
"github.com/thanos-io/thanos/pkg/compact"

baseAPI "github.com/thanos-io/thanos/pkg/api"
"github.com/thanos-io/thanos/pkg/component"
"github.com/thanos-io/thanos/pkg/gate"
"github.com/thanos-io/thanos/pkg/query"
Expand Down Expand Up @@ -197,7 +198,6 @@ func TestQueryEndpoints(t *testing.T) {
queryRangeHist: promauto.With(prometheus.NewRegistry()).NewHistogram(prometheus.HistogramOpts{
Name: "query_range_hist",
}),
seriesStatsAggregator: &store.NoopSeriesStatsAggregator{},
}

start := time.Unix(0, 0)
Expand Down Expand Up @@ -737,7 +737,6 @@ func TestMetadataEndpoints(t *testing.T) {
queryRangeHist: promauto.With(prometheus.NewRegistry()).NewHistogram(prometheus.HistogramOpts{
Name: "query_range_hist",
}),
seriesStatsAggregator: &store.NoopSeriesStatsAggregator{},
}
apiWithLabelLookback := &QueryAPI{
baseAPI: &baseAPI.BaseAPI{
Expand All @@ -751,7 +750,6 @@ func TestMetadataEndpoints(t *testing.T) {
queryRangeHist: promauto.With(prometheus.NewRegistry()).NewHistogram(prometheus.HistogramOpts{
Name: "query_range_hist",
}),
seriesStatsAggregator: &store.NoopSeriesStatsAggregator{},
}

var tests = []endpointTestCase{
Expand Down
Loading

0 comments on commit 3d6dd07

Please sign in to comment.