Skip to content

Commit

Permalink
Change to queryFrontend instead of query_frontend
Browse files Browse the repository at this point in the history
Signed-off-by: Jéssica Lins <[email protected]>
  • Loading branch information
Jéssica Lins committed Nov 12, 2021
1 parent 429eb66 commit dc01f84
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 228 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
- [#4576](https://github.com/thanos-io/thanos/pull/4576) UI: add filter compaction level to the Block UI.
- [#4731](https://github.com/thanos-io/thanos/pull/4731) Rule: add stateless mode to ruler according to https://thanos.io/tip/proposals-accepted/202005-scalable-rule-storage.md/. Continue https://github.com/thanos-io/thanos/pull/4250.
- [#4612](https://github.com/thanos-io/thanos/pull/4612) Sidecar: add `--prometheus.http-client` and `--prometheus.http-client-file` flag for sidecar to connect Prometheus with basic auth or TLS.
- [#4848](https://github.com/thanos-io/thanos/pull/4848) Compactor: added Prometheus metric for tracking the progress of retention.
- [#4856](https://github.com/thanos-io/thanos/pull/4856) Mixin: Add Query Frontend Grafana dashboard.

### Fixed
Expand Down
12 changes: 1 addition & 11 deletions cmd/thanos/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,6 @@ func runCompact(
if conf.compactionProgressMetrics {
g.Add(func() error {
ps := compact.NewCompactionProgressCalculator(reg, tsdbPlanner)
rs := compact.NewRetentionProgressCalculator(reg, retentionByResolution)
var ds *compact.DownsampleProgressCalculator
if !conf.disableDownsampling {
ds = compact.NewDownsampleProgressCalculator(reg)
Expand All @@ -477,22 +476,13 @@ func runCompact(
metas := sy.Metas()
groups, err := grouper.Groups(metas)
if err != nil {
return errors.Wrapf(err, "could not group metadata for compaction")
return errors.Wrapf(err, "could not group metadata")
}

if err = ps.ProgressCalculate(ctx, groups); err != nil {
return errors.Wrapf(err, "could not calculate compaction progress")
}

retGroups, err := grouper.Groups(metas)
if err != nil {
return errors.Wrapf(err, "could not group metadata for retention")
}

if err = rs.ProgressCalculate(ctx, retGroups); err != nil {
return errors.Wrapf(err, "could not calculate retention progress")
}

if !conf.disableDownsampling {
groups, err = grouper.Groups(metas)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion examples/dashboards/dashboards.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ There exists Grafana dashboards for each component (not all of them complete) ta
- [Thanos Overview](overview.json)
- [Thanos Compact](compact.json)
- [Thanos Querier](query.json)
- [Thanos Query Frontend](query_frontend.json)
- [Thanos Query Frontend](queryFrontend.json)
- [Thanos Store](store.json)
- [Thanos Receiver](receive.json)
- [Thanos Sidecar](sidecar.json)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,6 @@
},
"timezone": "UTC",
"title": "Thanos / Query Frontend",
"uid": "303c4e660a475c4c8cf6aee97da3a24a",
"uid": "9bc9f8bb21d4d18193c3fe772b36c306",
"version": 0
}
2 changes: 1 addition & 1 deletion mixin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ This project is intended to be used as a library. You can extend and customize d
selector: 'job=~".*thanos-query.*"',
title: '%(prefix)sQuery' % $.dashboard.prefix,
},
query_frontend+:: {
queryFrontend+:: {
selector: 'job=~".*thanos-query-frontend.*"',
title: '%(prefix)sQuery Frontend' % $.dashboard.prefix,
},
Expand Down
2 changes: 1 addition & 1 deletion mixin/config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
selector: 'job=~".*thanos-query.*"',
title: '%(prefix)sQuery' % $.dashboard.prefix,
},
query_frontend+:: {
queryFrontend+:: {
selector: 'job=~".*thanos-query-frontend.*"',
title: '%(prefix)sQuery Frontend' % $.dashboard.prefix,
},
Expand Down
32 changes: 16 additions & 16 deletions mixin/dashboards/query_frontend.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local utils = import '../lib/utils.libsonnet';

{
local thanos = self,
query_frontend+:: {
queryFrontend+:: {
selector: error 'must provide selector for Thanos Query Frontend dashboard',
title: error 'must provide title for Thanos Query Frontend dashboard',
dashboard:: {
Expand All @@ -12,71 +12,71 @@ local utils = import '../lib/utils.libsonnet';
},
},
grafanaDashboards+:: {
[if thanos.query_frontend != null then 'query_frontend.json']:
local queryFrontendHandlerSelector = utils.joinLabels([thanos.query_frontend.dashboard.selector, 'handler="query-frontend"']);
local queryFrontendTripperwareSelector = utils.joinLabels([thanos.query_frontend.dashboard.selector, 'tripperware="query_range"']);
local queryFrontendOpSelector = utils.joinLabels([thanos.query_frontend.dashboard.selector, 'op="query_range"']);
g.dashboard(thanos.query_frontend.title)
[if thanos.queryFrontend != null then 'queryFrontend.json']:
local queryFrontendHandlerSelector = utils.joinLabels([thanos.queryFrontend.dashboard.selector, 'handler="query-frontend"']);
local queryFrontendTripperwareSelector = utils.joinLabels([thanos.queryFrontend.dashboard.selector, 'tripperware="query_range"']);
local queryFrontendOpSelector = utils.joinLabels([thanos.queryFrontend.dashboard.selector, 'op="query_range"']);
g.dashboard(thanos.queryFrontend.title)
.addRow(
g.row('Query Frontend API')
.addPanel(
g.panel('Rate of requests', 'Shows rate of requests against Query Frontend for the given time.') +
g.httpQpsPanel('http_requests_total', queryFrontendHandlerSelector, thanos.query_frontend.dashboard.dimensions)
g.httpQpsPanel('http_requests_total', queryFrontendHandlerSelector, thanos.queryFrontend.dashboard.dimensions)
)
.addPanel(
g.panel('Rate of queries', 'Shows rate of queries passing through Query Frontend') +
g.httpQpsPanel('thanos_query_frontend_queries_total', queryFrontendOpSelector, thanos.query_frontend.dashboard.dimensions)
g.httpQpsPanel('thanos_query_frontend_queries_total', queryFrontendOpSelector, thanos.queryFrontend.dashboard.dimensions)
)
.addPanel(
g.panel('Errors', 'Shows ratio of errors compared to the the total number of handled requests against Query Frontend.') +
g.httpErrPanel('http_requests_total', queryFrontendHandlerSelector, thanos.query_frontend.dashboard.dimensions)
g.httpErrPanel('http_requests_total', queryFrontendHandlerSelector, thanos.queryFrontend.dashboard.dimensions)
)
.addPanel(
g.panel('Duration', 'Shows how long has it taken to handle requests in quantiles.') +
g.latencyPanel('http_request_duration_seconds', queryFrontendHandlerSelector, thanos.query_frontend.dashboard.dimensions)
g.latencyPanel('http_request_duration_seconds', queryFrontendHandlerSelector, thanos.queryFrontend.dashboard.dimensions)
)
)
.addRow(
g.row('Cache Operations')
.addPanel(
g.panel('Requests', 'Show rate of cache requests.') +
g.queryPanel(
'sum by (%s) (rate(cortex_cache_request_duration_seconds_count{%s}[$interval]))' % [utils.joinLabels([thanos.query_frontend.dashboard.dimensions, 'tripperware']), thanos.query_frontend.dashboard.selector],
'sum by (%s) (rate(cortex_cache_request_duration_seconds_count{%s}[$interval]))' % [utils.joinLabels([thanos.queryFrontend.dashboard.dimensions, 'tripperware']), thanos.queryFrontend.dashboard.selector],
'{{job}} {{tripperware}}',
) +
g.stack
)
.addPanel(
g.panel('Querier cache gets vs misses', 'Show rate of Querier cache gets vs misses.') +
g.queryPanel(
'sum by (%s) (rate(querier_cache_gets_total{%s}[$interval]))' % [utils.joinLabels([thanos.query_frontend.dashboard.dimensions, 'tripperware']), thanos.query_frontend.dashboard.selector],
'sum by (%s) (rate(querier_cache_gets_total{%s}[$interval]))' % [utils.joinLabels([thanos.queryFrontend.dashboard.dimensions, 'tripperware']), thanos.queryFrontend.dashboard.selector],
'Cache gets - {{job}} {{tripperware}}',
) +
g.queryPanel(
'sum by (%s) (rate(querier_cache_misses_total{%s}[$interval]))' % [utils.joinLabels([thanos.query_frontend.dashboard.dimensions, 'tripperware']), thanos.query_frontend.dashboard.selector],
'sum by (%s) (rate(querier_cache_misses_total{%s}[$interval]))' % [utils.joinLabels([thanos.queryFrontend.dashboard.dimensions, 'tripperware']), thanos.queryFrontend.dashboard.selector],
'Cache misses - {{job}} {{tripperware}}',
) +
g.stack
)
.addPanel(
g.panel('Cortex fetched keys', 'Shows rate of cortex fetched keys.') +
g.queryPanel(
'sum by (%s) (rate(cortex_cache_fetched_keys{%s}[$interval]))' % [utils.joinLabels([thanos.query_frontend.dashboard.dimensions, 'tripperware']), thanos.query_frontend.dashboard.selector],
'sum by (%s) (rate(cortex_cache_fetched_keys{%s}[$interval]))' % [utils.joinLabels([thanos.queryFrontend.dashboard.dimensions, 'tripperware']), thanos.queryFrontend.dashboard.selector],
'{{job}} {{tripperware}}',
) +
g.stack
)
.addPanel(
g.panel('Cortex cache hits', 'Shows rate of cortex cache hits.') +
g.queryPanel(
'sum by (%s) (rate(cortex_cache_hits{%s}[$interval]))' % [utils.joinLabels([thanos.query_frontend.dashboard.dimensions, 'tripperware']), thanos.query_frontend.dashboard.selector],
'sum by (%s) (rate(cortex_cache_hits{%s}[$interval]))' % [utils.joinLabels([thanos.queryFrontend.dashboard.dimensions, 'tripperware']), thanos.queryFrontend.dashboard.selector],
'{{job}} {{tripperware}}',
) +
g.stack
)
)
.addRow(
g.resourceUtilizationRow(thanos.query_frontend.dashboard.selector, thanos.query_frontend.dashboard.dimensions)
g.resourceUtilizationRow(thanos.queryFrontend.dashboard.selector, thanos.queryFrontend.dashboard.dimensions)
),
},
}
49 changes: 0 additions & 49 deletions pkg/compact/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,55 +667,6 @@ func (ds *DownsampleProgressCalculator) ProgressCalculate(ctx context.Context, g
return nil
}

// RetentionProgressMetrics contains Prometheus metrics related to retention progress.
type RetentionProgressMetrics struct {
NumberOfBlocksToDelete *prometheus.GaugeVec
}

// RetentionProgressCalculator contains RetentionProgressMetrics, which are updated during the retention simulation process.
type RetentionProgressCalculator struct {
*RetentionProgressMetrics
retentionByResolution map[ResolutionLevel]time.Duration
}

// NewRetentionProgressCalculator creates a new RetentionProgressCalculator.
func NewRetentionProgressCalculator(reg prometheus.Registerer, retentionByResolution map[ResolutionLevel]time.Duration) *RetentionProgressCalculator {
return &RetentionProgressCalculator{
retentionByResolution: retentionByResolution,
RetentionProgressMetrics: &RetentionProgressMetrics{
NumberOfBlocksToDelete: promauto.With(reg).NewGaugeVec(prometheus.GaugeOpts{
Name: "thanos_compact_todo_deletion_blocks",
Help: "number of blocks that have crossed their retention period",
}, []string{"group"}),
},
}
}

// ProgressCalculate calculates the number of blocks to be retained for the given groups.
func (rs *RetentionProgressCalculator) ProgressCalculate(ctx context.Context, groups []*Group) error {
groupBlocks := make(map[string]int, len(groups))

for _, group := range groups {
for _, m := range group.metasByMinTime {
retentionDuration := rs.retentionByResolution[ResolutionLevel(m.Thanos.Downsample.Resolution)]
if retentionDuration.Seconds() == 0 {
continue
}
maxTime := time.Unix(m.MaxTime/1000, 0)
if time.Now().After(maxTime.Add(retentionDuration)) {
groupBlocks[group.key]++
}
}
}

rs.RetentionProgressMetrics.NumberOfBlocksToDelete.Reset()
for key, blocks := range groupBlocks {
rs.RetentionProgressMetrics.NumberOfBlocksToDelete.WithLabelValues(key).Add(float64(blocks))
}

return nil
}

// Planner returns blocks to compact.
type Planner interface {
// Plan returns a list of blocks that should be compacted into single one.
Expand Down
Loading

0 comments on commit dc01f84

Please sign in to comment.