Skip to content

Commit

Permalink
Upgraded Prometheus and TSDB deps.
Browse files Browse the repository at this point in the history
This PR does not add anything, however by upgrading Prometheus from 2.3.2 to master tip and same for TSDB it may affects few things.
Bigger packages we use and changes I found manually:
* prometheus/prometheus/discovery/file
  * [ENHANCEMENT] Discovery: Improve performance of previously slow updates of changes of targets. #4526 ?? cc @ivan-valkov
  * [BUGFIX] Wait for service discovery to stop before exiting #4508 ??
* prometheus/prometheus/promql:
  * [BUGFIX] PromQL: Fix a goroutine leak in the lexer/parser. #4858
  * [BUGFIX] Change max/min over_time to handle NaNs properly. #438
  * [BUGFIX] Check label name for `count_values` PromQL function. #4585
  * [BUGFIX] Ensure that vectors and matrices do not contain identical label-sets. #4589
  * [ENHANCEMENT] Optimize PromQL aggregations #4248
  * [BUGFIX] Only add LookbackDelta to vector selectors #4399
  * [BUGFIX] Reduce floating point errors in stddev and related functions #4533

* prometheus/prometheus/rules:
  * New metrics exposed! (prometheus evaluation!)
  * [ENHANCEMENT] Rules: Error out at load time for invalid templates, rather than at evaluation time. #4537

* prometheus/tsdb/index: Index reader optimizations.

There are things/fixes we may reuse in next PRs (TODO create gh issues for those):
* api changes (warnings support on Prometheus UI and Query API)
* UI fixes:
  * [ENHANCEMENT] Web UI: Support console queries at specific times. #4764
  * [ENHANCEMENT] Web UI: Avoid browser spell-checking in expression field. #472
* Use notifier package once prometheus/prometheus#5025 is merged.
* Ruler UI fixes:
 * [ENHANCEMENT] Show rule evaluation errors in UI #4457

Follopw up issues we can fix in further PRs:
* QueryAPI has now api/v1/labels that Thanos does not yet support. Created issue with details: #702
* #703

Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
  • Loading branch information
bwplotka committed Jan 7, 2019
1 parent 236401e commit 1245b0c
Show file tree
Hide file tree
Showing 26 changed files with 934 additions and 308 deletions.
38 changes: 16 additions & 22 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ ignored = ["github.com/improbable-eng/thanos/benchmark/*"]
name = "github.com/prometheus/common"

[[constraint]]
version = "v2.3.2"
# TODO(bwplotka): Move to released version once our recent fixes will be merged & released.
revision = "6e08029b56ae17c49e133d92a2792f6f119f2cbd"
name = "github.com/prometheus/prometheus"

[[override]]
Expand All @@ -46,7 +47,9 @@ ignored = ["github.com/improbable-eng/thanos/benchmark/*"]

[[constraint]]
name = "github.com/prometheus/tsdb"
revision = "bd832fc8274e8fe63999ac749daaaff9d881241f"
# TODO(bwplotka): Move to upstream version once https://github.com/prometheus/tsdb/pull/492 is merged.
revision = "fd04e0963c04a1fbd891be7552b50f58e357f75c"
source = "github.com/bwplotka/tsdb"

[[constraint]]
branch = "master"
Expand Down
10 changes: 5 additions & 5 deletions cmd/thanos/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import (
"text/template"
"time"

"github.com/prometheus/tsdb/labels"

"github.com/go-kit/kit/log"
"github.com/improbable-eng/thanos/pkg/block"
"github.com/improbable-eng/thanos/pkg/block/blockmeta"
"github.com/improbable-eng/thanos/pkg/objstore/client"
"github.com/improbable-eng/thanos/pkg/runutil"
"github.com/improbable-eng/thanos/pkg/verifier"
Expand All @@ -23,6 +22,7 @@ import (
"github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/tsdb/labels"
"golang.org/x/text/language"
"golang.org/x/text/message"
"gopkg.in/alecthomas/kingpin.v2"
Expand Down Expand Up @@ -254,7 +254,7 @@ func registerBucket(m map[string]setupFunc, app *kingpin.Application, name strin
defer cancel()

// Getting Metas.
var blockMetas []*block.Meta
var blockMetas []*blockmeta.Meta
if err = bkt.Iter(ctx, "", func(name string) error {
id, ok := block.IsBlockDir(name)
if !ok {
Expand All @@ -277,7 +277,7 @@ func registerBucket(m map[string]setupFunc, app *kingpin.Application, name strin
}
}

func printTable(blockMetas []*block.Meta, selectorLabels labels.Labels, sortBy []string) error {
func printTable(blockMetas []*blockmeta.Meta, selectorLabels labels.Labels, sortBy []string) error {
header := inspectColumns

var lines [][]string
Expand Down Expand Up @@ -355,7 +355,7 @@ func getKeysAlphabetically(labels map[string]string) []string {

// matchesSelector checks if blockMeta contains every label from
// the selector with the correct value
func matchesSelector(blockMeta *block.Meta, selectorLabels labels.Labels) bool {
func matchesSelector(blockMeta *blockmeta.Meta, selectorLabels labels.Labels) bool {
for _, l := range selectorLabels {
if v, ok := blockMeta.Thanos.Labels[l.Name]; !ok || v != l.Value {
return false
Expand Down
10 changes: 5 additions & 5 deletions cmd/thanos/downsample.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import (
"path/filepath"
"time"

"github.com/prometheus/tsdb/chunkenc"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/improbable-eng/thanos/pkg/block"
"github.com/improbable-eng/thanos/pkg/block/blockmeta"
"github.com/improbable-eng/thanos/pkg/compact/downsample"
"github.com/improbable-eng/thanos/pkg/objstore"
"github.com/improbable-eng/thanos/pkg/objstore/client"
Expand All @@ -23,6 +22,7 @@ import (
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/tsdb"
"github.com/prometheus/tsdb/chunkenc"
"gopkg.in/alecthomas/kingpin.v2"
)

Expand Down Expand Up @@ -105,7 +105,7 @@ func downsampleBucket(
if err := os.MkdirAll(dir, 0777); err != nil {
return errors.Wrap(err, "create dir")
}
var metas []*block.Meta
var metas []*blockmeta.Meta

err := bkt.Iter(ctx, "", func(name string) error {
id, ok := block.IsBlockDir(name)
Expand All @@ -119,7 +119,7 @@ func downsampleBucket(
}
defer runutil.CloseWithLogOnErr(logger, rc, "block reader")

var m block.Meta
var m blockmeta.Meta
if err := json.NewDecoder(rc).Decode(&m); err != nil {
return errors.Wrap(err, "decode meta")
}
Expand Down Expand Up @@ -201,7 +201,7 @@ func downsampleBucket(
return nil
}

func processDownsampling(ctx context.Context, logger log.Logger, bkt objstore.Bucket, m *block.Meta, dir string, resolution int64) error {
func processDownsampling(ctx context.Context, logger log.Logger, bkt objstore.Bucket, m *blockmeta.Meta, dir string, resolution int64) error {
begin := time.Now()
bdir := filepath.Join(dir, m.ULID.String())

Expand Down
11 changes: 10 additions & 1 deletion cmd/thanos/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,16 @@ func runQuery(
return stores.Get(), nil
}, selectorLset)
queryableCreator = query.NewQueryableCreator(logger, proxy, replicaLabel)
engine = promql.NewEngine(logger, reg, maxConcurrentQueries, queryTimeout)
engine = promql.NewEngine(
promql.EngineOpts{
Logger: logger,
Reg: reg,
MaxConcurrent: maxConcurrentQueries,
// TODO(bwplotka): Expose this as a flag: https://github.com/improbable-eng/thanos/issues/703
MaxSamples: math.MaxInt32,
Timeout: queryTimeout,
},
)
)
// Periodically update the store set with the addresses we see in our cluster.
{
Expand Down
11 changes: 4 additions & 7 deletions cmd/thanos/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ import (
"syscall"
"time"

"github.com/improbable-eng/thanos/pkg/extprom"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/improbable-eng/thanos/pkg/alert"
"github.com/improbable-eng/thanos/pkg/block"
"github.com/improbable-eng/thanos/pkg/block/blockmeta"
"github.com/improbable-eng/thanos/pkg/cluster"
"github.com/improbable-eng/thanos/pkg/discovery/cache"
"github.com/improbable-eng/thanos/pkg/discovery/dns"
"github.com/improbable-eng/thanos/pkg/extprom"
"github.com/improbable-eng/thanos/pkg/objstore/client"
"github.com/improbable-eng/thanos/pkg/runutil"
"github.com/improbable-eng/thanos/pkg/shipper"
Expand Down Expand Up @@ -290,7 +289,7 @@ func runRule(
ctx, cancel := context.WithCancel(context.Background())
ctx = tracing.ContextWithTracer(ctx, tracer)

notify := func(ctx context.Context, expr string, alerts ...*rules.Alert) error {
notify := func(ctx context.Context, expr string, alerts ...*rules.Alert) {
res := make([]*alert.Alert, 0, len(alerts))
for _, alrt := range alerts {
// Only send actually firing alerts.
Expand All @@ -309,8 +308,6 @@ func runRule(
res = append(res, a)
}
alertQ.Push(res)

return nil
}
mgr = rules.NewManager(&rules.ManagerOptions{
Context: ctx,
Expand Down Expand Up @@ -579,7 +576,7 @@ func runRule(
}
}()

s := shipper.New(logger, nil, dataDir, bkt, func() labels.Labels { return lset }, block.RulerSource)
s := shipper.New(logger, nil, dataDir, bkt, func() labels.Labels { return lset }, blockmeta.RulerSource)

ctx, cancel := context.WithCancel(context.Background())

Expand Down
4 changes: 2 additions & 2 deletions cmd/thanos/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/improbable-eng/thanos/pkg/block"
"github.com/improbable-eng/thanos/pkg/block/blockmeta"
"github.com/improbable-eng/thanos/pkg/cluster"
"github.com/improbable-eng/thanos/pkg/objstore/client"
"github.com/improbable-eng/thanos/pkg/reloader"
Expand Down Expand Up @@ -252,7 +252,7 @@ func runSidecar(
}
}()

s := shipper.New(logger, nil, dataDir, bkt, metadata.Labels, block.SidecarSource)
s := shipper.New(logger, nil, dataDir, bkt, metadata.Labels, blockmeta.SidecarSource)
ctx, cancel := context.WithCancel(context.Background())

g.Add(func() error {
Expand Down
Loading

0 comments on commit 1245b0c

Please sign in to comment.