Skip to content

Commit 3e43fbd

Browse files
committed
Merge branch 'master' into sync
* master: iter.go: error message typo correction (thanos-io#1376) Fix usage of $GOPATH in Makefile (thanos-io#1379) Moved Prometheus 2.11.1 and TSDB to 0.9.1 (thanos-io#1380) Store latest config hash and timestamp as metrics (thanos-io#1378) pkg/receive/handler.go: log errors (thanos-io#1372) receive: Hash-ring metrics (thanos-io#1363) receiver: avoid race of hashring (thanos-io#1371) feat compact: added readiness Prober (thanos-io#1297) Add changelog entry for S3 option (thanos-io#1361) Multipart features (thanos-io#1358) Added katacoda.yaml (thanos-io#1359) Remove deprecated option from example (thanos-io#1351) Move suggestion about admin API to appropriate place (thanos-io#1355)
2 parents 9c6af21 + 343c04c commit 3e43fbd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1224
-798
lines changed

CHANGELOG.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,24 @@ We use *breaking* word for marking changes that are not backward compatible (rel
1111

1212
## Unreleased.
1313

14+
### Added
15+
16+
- [#1358](https://github.com/thanos-io/thanos/pull/1358) Added `part_size` configuration option for HTTP multipart requests minimum part size for S3 storage type
17+
- [#1363](https://github.com/thanos-io/thanos/pull/1363) Thanos Receive now exposes `thanos_receive_hashring_nodes` and `thanos_receive_hashring_tenants` metrics to monitor status of hash-rings
18+
19+
### Changed
20+
21+
- [#1380](https://github.com/thanos-io/thanos/pull/1380) Upgraded important dependencies: Prometheus to 2.11.1 and TSDB to 0.9.1. Some changes affecting Querier:
22+
- [ENHANCEMENT] Query performance improvement: Efficient iteration and search in HashForLabels and HashWithoutLabels. #5707
23+
- [ENHANCEMENT] Optimize queries using regexp for set lookups. tsdb#602
24+
- [BUGFIX] prometheus_tsdb_compactions_failed_total is now incremented on any compaction failure. tsdb#613
25+
- [BUGFIX] PromQL: Correctly display {__name__="a"}. #5552
1426
- [#1338](https://github.com/thanos-io/thanos/pull/1338) Querier still warns on store API duplicate, but allows a single one from duplicated set. This is gracefully warn about the problematic logic and not disrupt immediately.
27+
- [#1297](https://github.com/improbable-eng/thanos/pull/1297) Added `/-/ready` and `/-/healthy` endpoints to Thanos compact.
1528

1629
### Fixed
1730

1831
- [#1327](https://github.com/thanos-io/thanos/pull/1327) `/series` API end-point now properly returns an empty array just like Prometheus if there are no results
19-
2032
- [#1302](https://github.com/thanos-io/thanos/pull/1302) Thanos now efficiently reuses HTTP keep-alive connections
2133

2234
## [v0.6.0](https://github.com/thanos-io/thanos/releases/tag/v0.6.0) - 2019.07.18
@@ -59,7 +71,7 @@ The other `type` you can use is `JAEGER` now. The `config` keys and values are J
5971

6072
### Changed
6173

62-
- [#1284](https://github.com/thanos-io/thanos/pull/1284) Add support for multiple label-sets in Info gRPC service.
74+
- [#1284](https://github.com/thanos-io/thanos/pull/1284) Add support for multiple label-sets in Info gRPC service.
6375
This deprecates the single `Labels` slice of the `InfoResponse`, in a future release backward compatible handling for the single set of Labels will be removed. Upgrading to v0.6.0 or higher is advised.
6476
*breaking* If you run have duplicate queries in your Querier configuration with hierarchical federation of multiple Queries this PR makes Thanos Querier to detect this case and block all duplicates. Refer to 0.6.1 which at least allows for single replica to work.
6577

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ DOCKER_IMAGE_NAME ?= thanos
55
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))-$(shell date +%Y-%m-%d)-$(shell git rev-parse --short HEAD)
66

77
TMP_GOPATH ?= /tmp/thanos-go
8-
GOBIN ?= ${GOPATH}/bin
8+
GOBIN ?= $(firstword $(subst :, ,$GOPATH))/bin
99
GO111MODULE ?= on
1010
export GO111MODULE
1111
GOPROXY ?= https://proxy.golang.org

cmd/thanos/compact.go

+20-14
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@ import (
1515
"github.com/go-kit/kit/log"
1616
"github.com/go-kit/kit/log/level"
1717
"github.com/oklog/run"
18-
opentracing "github.com/opentracing/opentracing-go"
18+
"github.com/opentracing/opentracing-go"
1919
"github.com/pkg/errors"
2020
"github.com/prometheus/client_golang/prometheus"
2121
"github.com/prometheus/tsdb"
2222
"github.com/thanos-io/thanos/pkg/block"
2323
"github.com/thanos-io/thanos/pkg/block/metadata"
2424
"github.com/thanos-io/thanos/pkg/compact"
2525
"github.com/thanos-io/thanos/pkg/compact/downsample"
26+
"github.com/thanos-io/thanos/pkg/component"
2627
"github.com/thanos-io/thanos/pkg/objstore"
2728
"github.com/thanos-io/thanos/pkg/objstore/client"
29+
"github.com/thanos-io/thanos/pkg/prober"
2830
"github.com/thanos-io/thanos/pkg/runutil"
29-
kingpin "gopkg.in/alecthomas/kingpin.v2"
31+
"gopkg.in/alecthomas/kingpin.v2"
3032
)
3133

3234
var (
@@ -49,7 +51,7 @@ func (cs compactionSet) String() string {
4951
return strings.Join(result, ", ")
5052
}
5153

52-
// levels returns set of compaction levels not higher than specified max compaction level
54+
// levels returns set of compaction levels not higher than specified max compaction level.
5355
func (cs compactionSet) levels(maxLevel int) ([]int64, error) {
5456
if maxLevel >= len(cs) {
5557
return nil, errors.Errorf("level is bigger then default set of %d", len(cs))
@@ -62,13 +64,14 @@ func (cs compactionSet) levels(maxLevel int) ([]int64, error) {
6264
return levels, nil
6365
}
6466

65-
// maxLevel returns max available compaction level
67+
// maxLevel returns max available compaction level.
6668
func (cs compactionSet) maxLevel() int {
6769
return len(cs) - 1
6870
}
6971

70-
func registerCompact(m map[string]setupFunc, app *kingpin.Application, name string) {
71-
cmd := app.Command(name, "continuously compacts blocks in an object store bucket")
72+
func registerCompact(m map[string]setupFunc, app *kingpin.Application) {
73+
comp := component.Compact
74+
cmd := app.Command(comp.String(), "continuously compacts blocks in an object store bucket")
7275

7376
haltOnError := cmd.Flag("debug.halt-on-error", "Halt the process if a critical compaction error is detected.").
7477
Hidden().Default("true").Bool()
@@ -110,7 +113,7 @@ func registerCompact(m map[string]setupFunc, app *kingpin.Application, name stri
110113
compactionConcurrency := cmd.Flag("compact.concurrency", "Number of goroutines to use when compacting groups.").
111114
Default("1").Int()
112115

113-
m[name] = func(g *run.Group, logger log.Logger, reg *prometheus.Registry, tracer opentracing.Tracer, _ bool) error {
116+
m[comp.String()] = func(g *run.Group, logger log.Logger, reg *prometheus.Registry, tracer opentracing.Tracer, _ bool) error {
114117
return runCompact(g, logger, reg,
115118
*httpAddr,
116119
*dataDir,
@@ -125,7 +128,7 @@ func registerCompact(m map[string]setupFunc, app *kingpin.Application, name stri
125128
compact.ResolutionLevel5m: time.Duration(*retention5m),
126129
compact.ResolutionLevel1h: time.Duration(*retention1h),
127130
},
128-
name,
131+
comp,
129132
*disableDownsampling,
130133
*maxCompactionLevel,
131134
*blockSyncConcurrency,
@@ -147,7 +150,7 @@ func runCompact(
147150
wait bool,
148151
generateMissingIndexCacheFiles bool,
149152
retentionByResolution map[compact.ResolutionLevel]time.Duration,
150-
component string,
153+
component component.Component,
151154
disableDownsampling bool,
152155
maxCompactionLevel int,
153156
blockSyncConcurrency int,
@@ -168,12 +171,18 @@ func runCompact(
168171

169172
downsampleMetrics := newDownsampleMetrics(reg)
170173

174+
readinessProber := prober.NewProber(component, logger, prometheus.WrapRegistererWithPrefix("thanos_", reg))
175+
// Initiate default HTTP listener providing metrics endpoint and readiness/liveness probes.
176+
if err := defaultHTTPListener(g, logger, reg, httpBindAddr, readinessProber); err != nil {
177+
return errors.Wrap(err, "create readiness prober")
178+
}
179+
171180
confContentYaml, err := objStoreConfig.Content()
172181
if err != nil {
173182
return err
174183
}
175184

176-
bkt, err := client.NewBucket(logger, confContentYaml, reg, component)
185+
bkt, err := client.NewBucket(logger, confContentYaml, reg, component.String())
177186
if err != nil {
178187
return err
179188
}
@@ -318,11 +327,8 @@ func runCompact(
318327
cancel()
319328
})
320329

321-
if err := metricHTTPListenGroup(g, logger, reg, httpBindAddr); err != nil {
322-
return err
323-
}
324-
325330
level.Info(logger).Log("msg", "starting compact node")
331+
readinessProber.SetReady()
326332
return nil
327333
}
328334

cmd/thanos/main.go

+28-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/prometheus/client_golang/prometheus"
3232
"github.com/prometheus/client_golang/prometheus/promhttp"
3333
"github.com/prometheus/common/version"
34+
"github.com/thanos-io/thanos/pkg/prober"
3435
"github.com/thanos-io/thanos/pkg/runutil"
3536
"github.com/thanos-io/thanos/pkg/tracing"
3637
"github.com/thanos-io/thanos/pkg/tracing/client"
@@ -73,7 +74,7 @@ func main() {
7374
registerStore(cmds, app, "store")
7475
registerQuery(cmds, app, "query")
7576
registerRule(cmds, app, "rule")
76-
registerCompact(cmds, app, "compact")
77+
registerCompact(cmds, app)
7778
registerBucket(cmds, app, "bucket")
7879
registerDownsample(cmds, app, "downsample")
7980
registerReceive(cmds, app, "receive")
@@ -122,7 +123,7 @@ func main() {
122123
)
123124

124125
prometheus.DefaultRegisterer = metrics
125-
// Memberlist uses go-metrics
126+
// Memberlist uses go-metrics.
126127
sink, err := gprom.NewPrometheusSink()
127128
if err != nil {
128129
fmt.Fprintln(os.Stderr, errors.Wrapf(err, "%s command failed", cmd))
@@ -311,6 +312,7 @@ func defaultGRPCServerOpts(logger log.Logger, reg *prometheus.Registry, tracer o
311312
return append(opts, grpc.Creds(credentials.NewTLS(tlsCfg))), nil
312313
}
313314

315+
// TODO Remove once all components are migrated to the new defaultHTTPListener.
314316
// metricHTTPListenGroup is a run.Group that servers HTTP endpoint with only Prometheus metrics.
315317
func metricHTTPListenGroup(g *run.Group, logger log.Logger, reg *prometheus.Registry, httpBindAddr string) error {
316318
mux := http.NewServeMux()
@@ -330,3 +332,27 @@ func metricHTTPListenGroup(g *run.Group, logger log.Logger, reg *prometheus.Regi
330332
})
331333
return nil
332334
}
335+
336+
// defaultHTTPListener starts a run.Group that servers HTTP endpoint with default endpoints providing Prometheus metrics,
337+
// profiling and liveness/readiness probes.
338+
func defaultHTTPListener(g *run.Group, logger log.Logger, reg *prometheus.Registry, httpBindAddr string, readinessProber *prober.Prober) error {
339+
mux := http.NewServeMux()
340+
registerMetrics(mux, reg)
341+
registerProfile(mux)
342+
readinessProber.RegisterInMux(mux)
343+
344+
l, err := net.Listen("tcp", httpBindAddr)
345+
if err != nil {
346+
return errors.Wrap(err, "listen metrics address")
347+
}
348+
349+
g.Add(func() error {
350+
level.Info(logger).Log("msg", "listening for metrics", "address", httpBindAddr)
351+
readinessProber.SetHealthy()
352+
return errors.Wrap(http.Serve(l, mux), "serve metrics")
353+
}, func(err error) {
354+
readinessProber.SetNotHealthy(err)
355+
runutil.CloseWithLogOnErr(logger, l, "metric listener")
356+
})
357+
return nil
358+
}

docs/components/store.md

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ It keeps a small amount of information about all remote blocks on local disk and
1212
```bash
1313
$ thanos store \
1414
--data-dir "/local/state/data/dir" \
15-
--cluster.peers "thanos-cluster.example.org" \
1615
--objstore.config-file "bucket.yml"
1716
```
1817

docs/storage.md

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ config:
6262
insecure_skip_verify: false
6363
trace:
6464
enable: false
65+
part_size: 0
6566
```
6667
6768
At a minimum, you will need to provide a value for the `bucket`, `endpoint`, `access_key`, and `secret_key` keys. The rest of the keys are optional.
@@ -74,6 +75,8 @@ You can configure the timeout settings for the HTTP client by setting the `http_
7475

7576
Please refer to the documentation of [the Transport type](https://golang.org/pkg/net/http/#Transport) in the `net/http` package for detailed information on what each option does.
7677

78+
`part_size` is specified in bytes and refers to the minimum file size used for multipart uploads, as some custom S3 implementations may have different requirements. A value of `0` means to use a default 128 MiB size.
79+
7780
For debug and testing purposes you can set
7881

7982
* `insecure: true` to switch to plain insecure HTTP instead of HTTPS

go.mod

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ require (
44
cloud.google.com/go v0.34.0
55
github.com/Azure/azure-storage-blob-go v0.7.0
66
github.com/NYTimes/gziphandler v1.1.1
7+
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
78
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da
89
github.com/cespare/xxhash v1.1.0
910
github.com/fatih/structtag v1.0.0
@@ -33,8 +34,8 @@ require (
3334
github.com/pkg/errors v0.8.1
3435
github.com/prometheus/client_golang v1.0.0
3536
github.com/prometheus/common v0.6.0
36-
github.com/prometheus/prometheus v2.9.2+incompatible
37-
github.com/prometheus/tsdb v0.8.0
37+
github.com/prometheus/prometheus v0.0.0-20190710134608-e5b22494857d
38+
github.com/prometheus/tsdb v0.9.1
3839
github.com/uber-go/atomic v1.4.0 // indirect
3940
github.com/uber/jaeger-client-go v2.16.0+incompatible
4041
github.com/uber/jaeger-lib v2.0.0+incompatible

0 commit comments

Comments
 (0)