Skip to content

Commit e99000f

Browse files
committed
add wal compression option in rule and receive
Signed-off-by: yeya24 <yb532204897@gmail.com>
1 parent d9764fb commit e99000f

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ We use *breaking* word for marking changes that are not backward compatible (rel
2424
- [#1838](https://github.com/thanos-io/thanos/pull/1838) Ruler: Add a new `--alertmanagers.sd-dns-interval` CLI option to specify the interval between DNS resolutions of Alertmanager hosts.
2525
- [#1881](https://github.com/thanos-io/thanos/pull/1881) Store Gateway: memcached support for index cache. See [documentation](docs/components/store.md/#index-cache) for further information.
2626
- [#1904](https://github.com/thanos-io/thanos/pull/1904) Add a skip-chunks option in Store Series API to improve the response time of `/api/v1/series` endpoint.
27+
- [#1933](https://github.com/thanos-io/thanos/pull/1933) Add a flag `--tsdb.wal-compression` to configure whether to enable tsdb wal compression in ruler and receiver.
2728

2829
## [v0.9.0](https://github.com/thanos-io/thanos/releases/tag/v0.9.0) - 2019.12.03
2930

cmd/thanos/receive.go

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
opentracing "github.com/opentracing/opentracing-go"
1414
"github.com/pkg/errors"
1515
"github.com/prometheus/client_golang/prometheus"
16-
"github.com/prometheus/common/model"
1716
"github.com/prometheus/prometheus/pkg/labels"
1817
"github.com/prometheus/prometheus/storage/tsdb"
1918
"github.com/thanos-io/thanos/pkg/block/metadata"
@@ -73,6 +72,8 @@ func registerReceive(m map[string]setupFunc, app *kingpin.Application) {
7372

7473
tsdbBlockDuration := modelDuration(cmd.Flag("tsdb.block-duration", "Duration for local TSDB blocks").Default("2h").Hidden())
7574

75+
walCompression := cmd.Flag("tsdb.wal-compression", "Compress the tsdb WAL.").Default("false").Bool()
76+
7677
m[comp.String()] = func(g *run.Group, logger log.Logger, reg *prometheus.Registry, tracer opentracing.Tracer, _ bool) error {
7778
lset, err := parseFlagLabels(*labelStrs)
7879
if err != nil {
@@ -87,6 +88,14 @@ func registerReceive(m map[string]setupFunc, app *kingpin.Application) {
8788
}
8889
}
8990

91+
tsdbOpts := &tsdb.Options{
92+
MinBlockDuration: *tsdbBlockDuration,
93+
MaxBlockDuration: *tsdbBlockDuration,
94+
RetentionDuration: *retention,
95+
NoLockfile: true,
96+
WALCompression: *walCompression,
97+
}
98+
9099
// Local is empty, so try to generate a local endpoint
91100
// based on the hostname and the listening port.
92101
if *local == "" {
@@ -121,14 +130,13 @@ func registerReceive(m map[string]setupFunc, app *kingpin.Application) {
121130
*rwClientServerName,
122131
*dataDir,
123132
objStoreConfig,
133+
tsdbOpts,
124134
lset,
125-
*retention,
126135
cw,
127136
*local,
128137
*tenantHeader,
129138
*replicaHeader,
130139
*replicationFactor,
131-
*tsdbBlockDuration,
132140
comp,
133141
)
134142
}
@@ -156,27 +164,18 @@ func runReceive(
156164
rwClientServerName string,
157165
dataDir string,
158166
objStoreConfig *extflag.PathOrContent,
167+
tsdbOpts *tsdb.Options,
159168
lset labels.Labels,
160-
retention model.Duration,
161169
cw *receive.ConfigWatcher,
162170
endpoint string,
163171
tenantHeader string,
164172
replicaHeader string,
165173
replicationFactor uint64,
166-
tsdbBlockDuration model.Duration,
167174
comp component.SourceStoreAPI,
168175
) error {
169176
logger = log.With(logger, "component", "receive")
170177
level.Warn(logger).Log("msg", "setting up receive; the Thanos receive component is EXPERIMENTAL, it may break significantly without notice")
171178

172-
tsdbCfg := &tsdb.Options{
173-
RetentionDuration: retention,
174-
NoLockfile: true,
175-
MinBlockDuration: tsdbBlockDuration,
176-
MaxBlockDuration: tsdbBlockDuration,
177-
WALCompression: true,
178-
}
179-
180179
localStorage := &tsdb.ReadyStorage{}
181180
rwTLSConfig, err := tls.NewServerConfig(log.With(logger, "protocol", "HTTP"), rwServerCert, rwServerKey, rwServerClientCA)
182181
if err != nil {
@@ -225,7 +224,7 @@ func runReceive(
225224
{
226225
// TSDB.
227226
cancel := make(chan struct{})
228-
startTimeMargin := int64(2 * time.Duration(tsdbCfg.MinBlockDuration).Seconds() * 1000)
227+
startTimeMargin := int64(2 * time.Duration(tsdbOpts.MinBlockDuration).Seconds() * 1000)
229228
g.Add(func() error {
230229
defer close(dbReady)
231230
defer close(uploadC)
@@ -237,7 +236,7 @@ func runReceive(
237236
dataDir,
238237
log.With(logger, "component", "tsdb"),
239238
reg,
240-
tsdbCfg,
239+
tsdbOpts,
241240
)
242241

243242
// Before quitting, ensure the WAL is flushed and the DB is closed.

cmd/thanos/rule.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ func registerRule(m map[string]setupFunc, app *kingpin.Application) {
7979
tsdbRetention := modelDuration(cmd.Flag("tsdb.retention", "Block retention time on local disk.").
8080
Default("48h"))
8181

82+
walCompression := cmd.Flag("tsdb.wal-compression", "Compress the tsdb WAL.").Default("false").Bool()
83+
8284
alertmgrs := cmd.Flag("alertmanagers.url", "Alertmanager replica URLs to push firing alerts. Ruler claims success if push to at least one alertmanager from discovered succeeds. The scheme should not be empty e.g `http` might be used. The scheme may be prefixed with 'dns+' or 'dnssrv+' to detect Alertmanager IPs through respective DNS lookups. The port defaults to 9093 or the SRV record's value. The URL path is used as a prefix for the regular Alertmanager API path.").
8385
Strings()
8486
alertmgrsTimeout := cmd.Flag("alertmanagers.send-timeout", "Timeout for sending alerts to Alertmanager").Default("10s").Duration()
@@ -126,6 +128,7 @@ func registerRule(m map[string]setupFunc, app *kingpin.Application) {
126128
MaxBlockDuration: *tsdbBlockDuration,
127129
RetentionDuration: *tsdbRetention,
128130
NoLockfile: true,
131+
WALCompression: *walCompression,
129132
}
130133

131134
lookupQueries := map[string]struct{}{}

docs/components/rule.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ Flags:
281281
--eval-interval=30s The default evaluation interval to use.
282282
--tsdb.block-duration=2h Block duration for TSDB block.
283283
--tsdb.retention=48h Block retention time on local disk.
284+
--tsdb.wal-compression Compress the tsdb WAL.
284285
--alertmanagers.url=ALERTMANAGERS.URL ...
285286
Alertmanager replica URLs to push firing
286287
alerts. Ruler claims success if push to at

0 commit comments

Comments
 (0)