-
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
Implement stateless mode for Thanos Ruler #4250
Closed
Closed
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
64a9700
import wal package from grafana/agent (with string interning disabled)
idoqo f651423
Set up remote-write config and test skeleton
idoqo 0e2b82f
Setup fanout and related storages for stateless ruler
idoqo 02f8981
Optionally run ruler in stateless mode
idoqo fc8f103
Set up tests and implementations for configuring remote-write for ruler
idoqo 44b6219
Implement stub querier for WAL storage to fix nil pointer error
idoqo a5e3a78
Setup e2e test for stateless ruler
idoqo f05fabd
Add copied code commentary to remotewrite packages
idoqo 7b87e52
Use static addresses for am and querier
idoqo 2729902
Remove need for separate remote-write flag for stateless ruler
idoqo 9e033d0
Generate docs for stateless ruler flags and fix tests
idoqo 64f4c26
Use promauto for prometheus primitives
idoqo 0290a3d
Group imports and satisfy go-lint
idoqo 77ee337
Always return empty series set from WAL storage
idoqo 933a875
re-generate rule documentation
idoqo 41d3408
copyright headers to satisfy golint
idoqo 79b06d3
Rename wal storage metrics
idoqo 6b0612c
Use Prometheus' remote write config instead of rolling another
idoqo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) The Thanos Authors. | ||
// Licensed under the Apache License 2.0. | ||
|
||
package remotewrite | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/pkg/errors" | ||
|
||
"github.com/go-kit/kit/log" | ||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/prometheus/prometheus/config" | ||
"github.com/prometheus/prometheus/storage" | ||
"github.com/prometheus/prometheus/storage/remote" | ||
"gopkg.in/yaml.v2" | ||
) | ||
|
||
// Config represents a remote write configuration for Thanos stateless ruler. | ||
type Config struct { | ||
idoqo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Name string `yaml:"name"` | ||
yeya24 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
RemoteStore *config.RemoteWriteConfig `yaml:"remote_write,omitempty"` | ||
} | ||
|
||
// LoadRemoteWriteConfig prepares a Config instance from a given YAML config. | ||
func LoadRemoteWriteConfig(configYAML []byte) (Config, error) { | ||
var cfg Config | ||
if err := yaml.Unmarshal(configYAML, &cfg); err != nil { | ||
return cfg, err | ||
} | ||
return cfg, nil | ||
} | ||
|
||
// NewFanoutStorage creates a storage that fans-out to both the WAL and a configured remote storage. | ||
// The remote storage tails the WAL and sends the metrics it reads using Prometheus' remote_write. | ||
func NewFanoutStorage(logger log.Logger, reg prometheus.Registerer, walDir string, rwConfig Config) (storage.Storage, error) { | ||
walStore, err := NewStorage(logger, reg, walDir) | ||
if err != nil { | ||
return nil, err | ||
} | ||
remoteStore := remote.NewStorage(logger, reg, walStore.StartTime, walStore.Directory(), 1*time.Minute, nil) | ||
yeya24 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if err := remoteStore.ApplyConfig(&config.Config{ | ||
GlobalConfig: config.DefaultGlobalConfig, | ||
RemoteWriteConfigs: []*config.RemoteWriteConfig{rwConfig.RemoteStore}, | ||
}); err != nil { | ||
return nil, errors.Wrap(err, "applying config to remote storage") | ||
} | ||
return storage.NewFanout(logger, walStore, remoteStore), nil | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@squat @bwplotka
In this case though, an empty
--remote-write.config
(or--remote-write.config-file
)will fall back to using the TSDB-backed ruler. This is becauselen(rwCfgYAML) == 0
either means:I couldn't think of a reliable way to distinguish between them. I've also documented this behavior in the flag help, but I don't know if it is something we want. An alternative would be to provide a separate flag for enabling stateless mode (e.g
--remote.write
or--remote-write.enabled
).