-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Metrics for compaction and downsampling process #4801
Changes from 64 commits
6fb9752
f403fcc
02d7037
ea83250
ff2e36a
5961552
a2b2b97
8f13acc
f52e056
ad639c1
845d497
cc4efe4
322340b
a4642f6
3092479
7f91580
5fd74c6
6f0b74a
ec3e767
a3dfae1
772041a
ad4c704
3c7b8ac
e6739d7
b4a662b
cdeb0d7
7a53935
3b90846
da04db8
8922b33
81a5066
63ab795
235528d
dc301ab
1810ba4
a355886
40fa1fc
13bec69
cec1c58
d8a1ab8
8b23ef3
fc71280
0460638
5ea12ef
3629986
fa40551
825a721
6b9b326
adba129
87e9667
4d7da02
a0ea1d4
5c5d7b6
d788f99
daea946
60bbe9e
9c3d11c
afd48bf
54b412f
8f1fff7
ff3ea04
fa5f03f
3c5cbce
35c4ff7
639b964
c0caf42
a58b63f
8ec72e6
e10c845
3d0d375
6999f7f
37848f1
e366232
50d1be4
02bb607
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ import ( | |
"github.com/thanos-io/thanos/pkg/logging" | ||
"github.com/thanos-io/thanos/pkg/objstore/client" | ||
"github.com/thanos-io/thanos/pkg/prober" | ||
"github.com/thanos-io/thanos/pkg/receive" | ||
"github.com/thanos-io/thanos/pkg/runutil" | ||
httpserver "github.com/thanos-io/thanos/pkg/server/http" | ||
"github.com/thanos-io/thanos/pkg/ui" | ||
|
@@ -353,8 +354,9 @@ func runCompact( | |
compactMetrics.blocksMarked.WithLabelValues(metadata.NoCompactMarkFilename, metadata.OutOfOrderChunksNoCompactReason), | ||
metadata.HashFunc(conf.hashFunc), | ||
) | ||
tsdbPlanner := compact.NewPlanner(logger, levels, noCompactMarkerFilter) | ||
planner := compact.WithLargeTotalIndexSizeFilter( | ||
compact.NewPlanner(logger, levels, noCompactMarkerFilter), | ||
tsdbPlanner, | ||
bkt, | ||
int64(conf.maxBlockIndexSize), | ||
compactMetrics.blocksMarked.WithLabelValues(metadata.NoCompactMarkFilename, metadata.IndexSizeExceedingNoCompactReason), | ||
|
@@ -458,6 +460,56 @@ func runCompact( | |
return cleanPartialMarked() | ||
} | ||
|
||
if conf.compactionProgressMetrics { | ||
g.Add(func() error { | ||
unRegisterer := &receive.UnRegisterer{Registerer: reg} | ||
ps := compact.NewCompactionProgressCalculator(unRegisterer, tsdbPlanner) | ||
var ds *compact.DownsampleProgressCalculator | ||
if !conf.disableDownsampling { | ||
ds = compact.NewDownsampleProgressCalculator(unRegisterer) | ||
} | ||
|
||
return runutil.Repeat(5*time.Minute, ctx.Done(), func() error { | ||
|
||
if err := sy.SyncMetas(ctx); err != nil { | ||
return errors.Wrapf(err, "could not sync metas") | ||
} | ||
|
||
metas := sy.Metas() | ||
groups, err := grouper.Groups(metas) | ||
if err != nil { | ||
return errors.Wrapf(err, "could not group original metadata") | ||
} | ||
|
||
for _, group := range groups { | ||
ps.CompactProgressMetrics.NumberOfCompactionRuns.WithLabelValues(group.Key()) | ||
ps.CompactProgressMetrics.NumberOfCompactionBlocks.WithLabelValues(group.Key()) | ||
} | ||
|
||
if err = ps.ProgressCalculate(ctx, groups); err != nil { | ||
return errors.Wrapf(err, "could not calculate compaction progress") | ||
} | ||
|
||
if !conf.disableDownsampling { | ||
yeya24 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
groups, err = grouper.Groups(metas) | ||
if err != nil { | ||
return errors.Wrapf(err, "could not group original metadata into downsample groups") | ||
} | ||
for _, group := range groups { | ||
ds.DownsampleProgressMetrics.NumberOfBlocksDownsampled.WithLabelValues(group.Key()) | ||
} | ||
if err := ds.ProgressCalculate(ctx, groups); err != nil { | ||
return errors.Wrapf(err, "could not calculate downsampling progress") | ||
} | ||
} | ||
|
||
return nil | ||
}) | ||
}, func(err error) { | ||
cancel() | ||
}) | ||
} | ||
|
||
g.Add(func() error { | ||
defer runutil.CloseWithLogOnErr(logger, bkt, "bucket client") | ||
|
||
|
@@ -590,9 +642,12 @@ type compactConfig struct { | |
enableVerticalCompaction bool | ||
dedupFunc string | ||
skipBlockWithOutOfOrderChunks bool | ||
compactionProgressMetrics bool | ||
} | ||
|
||
func (cc *compactConfig) registerFlag(cmd extkingpin.FlagClause) { | ||
cmd.Flag("progress-metrics", "Enables the progress metrics, indicating the progress of compaction and downsampling").Default("false").BoolVar(&cc.compactionProgressMetrics) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean why even have a flag for this? We get so many questions about how to tell whether Thanos Compact is progressing or not so I think this would be useful for everyone There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about still having a flag but default to true? I want users to be able to disable it as some clusters setup doesn't need to check compact backlog There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good 👍 |
||
|
||
cmd.Flag("debug.halt-on-error", "Halt the process if a critical compaction error is detected."). | ||
Hidden().Default("true").BoolVar(&cc.haltOnError) | ||
cmd.Flag("debug.accept-malformed-index", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to call it
orgininal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean in the log unnecessary to call it original. "Could not group metadata" is good enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still not solved @metonymic-smokey