Skip to content

Commit eb9a09e

Browse files
fix: Improve docs for min and max table offsets (#14890)
Co-authored-by: Christian Haudum <[email protected]> (cherry picked from commit fd9d332)
1 parent 1f6828b commit eb9a09e

File tree

3 files changed

+42
-10
lines changed

3 files changed

+42
-10
lines changed

docs/sources/shared/configuration.md

+9-8
Original file line numberDiff line numberDiff line change
@@ -1263,19 +1263,20 @@ planner:
12631263
# CLI flag: -bloom-build.planner.interval
12641264
[planning_interval: <duration> | default = 8h]
12651265
1266-
# Newest day-table offset (from today, inclusive) to build blooms for.
1267-
# Increase to lower cost by not re-writing data to object storage too
1268-
# frequently since recent data changes more often at the cost of not having
1269-
# blooms available as quickly.
1266+
# Newest day-table offset (from today, inclusive) to build blooms for. 0 start
1267+
# building from today, 1 from yesterday and so on. Increase to lower cost by
1268+
# not re-writing data to object storage too frequently since recent data
1269+
# changes more often at the cost of not having blooms available as quickly.
12701270
# CLI flag: -bloom-build.planner.min-table-offset
1271-
[min_table_offset: <int> | default = 1]
1271+
[min_table_offset: <int> | default = 0]
12721272
1273-
# Oldest day-table offset (from today, inclusive) to compact. This can be used
1274-
# to lower cost by not trying to compact older data which doesn't change. This
1273+
# Oldest day-table offset (from today, inclusive) to build blooms for. 1 till
1274+
# yesterday, 2 till day before yesterday and so on. This can be used to lower
1275+
# cost by not trying to build blooms for older data which doesn't change. This
12751276
# can be optimized by aligning it with the maximum
12761277
# `reject_old_samples_max_age` setting of any tenant.
12771278
# CLI flag: -bloom-build.planner.max-table-offset
1278-
[max_table_offset: <int> | default = 2]
1279+
[max_table_offset: <int> | default = 1]
12791280

12801281
retention:
12811282
# Enable bloom retention.

pkg/bloombuild/planner/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ type Config struct {
2121
// RegisterFlagsWithPrefix registers flags for the bloom-planner configuration.
2222
func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
2323
f.DurationVar(&cfg.PlanningInterval, prefix+".interval", 8*time.Hour, "Interval at which to re-run the bloom creation planning.")
24-
f.IntVar(&cfg.MinTableOffset, prefix+".min-table-offset", 1, "Newest day-table offset (from today, inclusive) to build blooms for. Increase to lower cost by not re-writing data to object storage too frequently since recent data changes more often at the cost of not having blooms available as quickly.")
24+
f.IntVar(&cfg.MinTableOffset, prefix+".min-table-offset", 0, "Newest day-table offset (from today, inclusive) to build blooms for. 0 start building from today, 1 from yesterday and so on. Increase to lower cost by not re-writing data to object storage too frequently since recent data changes more often at the cost of not having blooms available as quickly.")
2525
// TODO(owen-d): ideally we'd set this per tenant based on their `reject_old_samples_max_age` setting,
2626
// but due to how we need to discover tenants, we can't do that yet. Tenant+Period discovery is done by
2727
// iterating the table periods in object storage and looking for tenants within that period.
2828
// In order to have this done dynamically, we'd need to account for tenant specific overrides, which are also
2929
// dynamically reloaded.
3030
// I'm doing it the simple way for now.
31-
f.IntVar(&cfg.MaxTableOffset, prefix+".max-table-offset", 2, "Oldest day-table offset (from today, inclusive) to compact. This can be used to lower cost by not trying to compact older data which doesn't change. This can be optimized by aligning it with the maximum `reject_old_samples_max_age` setting of any tenant.")
31+
f.IntVar(&cfg.MaxTableOffset, prefix+".max-table-offset", 1, "Oldest day-table offset (from today, inclusive) to build blooms for. 1 till yesterday, 2 till day before yesterday and so on. This can be used to lower cost by not trying to build blooms for older data which doesn't change. This can be optimized by aligning it with the maximum `reject_old_samples_max_age` setting of any tenant.")
3232
cfg.RetentionConfig.RegisterFlagsWithPrefix(prefix+".retention", f)
3333
cfg.Queue.RegisterFlagsWithPrefix(prefix+".queue", f)
3434
}

pkg/bloombuild/planner/planner_test.go

+31
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/grafana/loki/v3/pkg/bloombuild/planner/queue"
2323
"github.com/grafana/loki/v3/pkg/bloombuild/planner/strategies"
2424
"github.com/grafana/loki/v3/pkg/bloombuild/protos"
25+
iter "github.com/grafana/loki/v3/pkg/iter/v2"
2526
"github.com/grafana/loki/v3/pkg/storage"
2627
v1 "github.com/grafana/loki/v3/pkg/storage/bloom/v1"
2728
"github.com/grafana/loki/v3/pkg/storage/chunk/cache"
@@ -606,6 +607,36 @@ func Test_deleteOutdatedMetas(t *testing.T) {
606607
}
607608
}
608609

610+
func TestMinMaxTables(t *testing.T) {
611+
logger := log.NewNopLogger()
612+
//logger := log.NewLogfmtLogger(os.Stdout)
613+
614+
cfg := Config{
615+
PlanningInterval: 1 * time.Hour,
616+
Queue: queue.Config{
617+
MaxQueuedTasksPerTenant: 10000,
618+
},
619+
// From today till day before tomorrow
620+
MinTableOffset: 0,
621+
MaxTableOffset: 2,
622+
}
623+
planner := createPlanner(t, cfg, &fakeLimits{}, logger)
624+
625+
tables := planner.tables(time.Now())
626+
require.Equal(t, 3, tables.TotalDays())
627+
628+
dayTables, err := iter.Collect(tables)
629+
require.NoError(t, err)
630+
631+
todayTable := config.NewDayTable(config.NewDayTime(model.Now()), "index_")
632+
yesterdayTable := config.NewDayTable(config.NewDayTime(model.Now().Add(-24*time.Hour)), "index_")
633+
dayBeforeYesterdayTable := config.NewDayTable(config.NewDayTime(model.Now().Add(-48*time.Hour)), "index_")
634+
635+
require.Equal(t, dayBeforeYesterdayTable.Addr(), dayTables[0].Addr())
636+
require.Equal(t, yesterdayTable.Addr(), dayTables[1].Addr())
637+
require.Equal(t, todayTable.Addr(), dayTables[2].Addr())
638+
}
639+
609640
type fakeBuilder struct {
610641
mx sync.Mutex // Protects tasks and currTaskIdx.
611642
id string

0 commit comments

Comments
 (0)