Skip to content

Commit de23a96

Browse files
authored
prw2: Split PRW2.0 from metadata-wal-records feature (prometheus#16030)
Rationales: * metadata-wal-records might be deprecated and replaced going forward: prometheus#15911 * PRW 2.0 works without metadata just fine (although it sends untyped metrics as expected). Signed-off-by: bwplotka <bwplotka@gmail.com>
1 parent 733a5e9 commit de23a96

File tree

10 files changed

+26
-33
lines changed

10 files changed

+26
-33
lines changed

cmd/prometheus/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func (c *flagConfig) setFeatureListOptions(logger *slog.Logger) error {
231231
logger.Info("Experimental additional scrape metrics enabled")
232232
case "metadata-wal-records":
233233
c.scrape.AppendMetadata = true
234-
logger.Info("Experimental metadata records in WAL enabled, required for remote write 2.0")
234+
logger.Info("Experimental metadata records in WAL enabled")
235235
case "promql-per-step-stats":
236236
c.enablePerStepStats = true
237237
logger.Info("Experimental per-step statistics reporting")
@@ -699,7 +699,7 @@ func main() {
699699
var (
700700
localStorage = &readyStorage{stats: tsdb.NewDBStats()}
701701
scraper = &readyScrapeManager{}
702-
remoteStorage = remote.NewStorage(logger.With("component", "remote"), prometheus.DefaultRegisterer, localStorage.StartTime, localStoragePath, time.Duration(cfg.RemoteFlushDeadline), scraper, cfg.scrape.AppendMetadata)
702+
remoteStorage = remote.NewStorage(logger.With("component", "remote"), prometheus.DefaultRegisterer, localStorage.StartTime, localStoragePath, time.Duration(cfg.RemoteFlushDeadline), scraper)
703703
fanoutStorage = storage.NewFanout(logger, localStorage, remoteStorage)
704704
)
705705

docs/feature_flags.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ Fall back to serving the old (Prometheus 2.x) web UI instead of the new UI. The
114114
When enabled, Prometheus will store metadata in-memory and keep track of
115115
metadata changes as WAL records on a per-series basis.
116116

117-
This must be used if
118-
you are also using remote write 2.0 as it will only gather metadata from the WAL.
117+
This must be used if you would like to send metadata using the new remote write 2.0.
119118

120119
## Delay compaction start time
121120

storage/remote/queue_manager_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func TestBasicContentNegotiation(t *testing.T) {
135135
} {
136136
t.Run(tc.name, func(t *testing.T) {
137137
dir := t.TempDir()
138-
s := NewStorage(nil, nil, nil, dir, defaultFlushDeadline, nil, true)
138+
s := NewStorage(nil, nil, nil, dir, defaultFlushDeadline, nil)
139139
defer s.Close()
140140

141141
var (
@@ -243,7 +243,7 @@ func TestSampleDelivery(t *testing.T) {
243243
} {
244244
t.Run(fmt.Sprintf("%s-%s", tc.protoMsg, tc.name), func(t *testing.T) {
245245
dir := t.TempDir()
246-
s := NewStorage(nil, nil, nil, dir, defaultFlushDeadline, nil, true)
246+
s := NewStorage(nil, nil, nil, dir, defaultFlushDeadline, nil)
247247
defer s.Close()
248248

249249
var (
@@ -362,7 +362,7 @@ func TestMetadataDelivery(t *testing.T) {
362362

363363
func TestWALMetadataDelivery(t *testing.T) {
364364
dir := t.TempDir()
365-
s := NewStorage(nil, nil, nil, dir, defaultFlushDeadline, nil, true)
365+
s := NewStorage(nil, nil, nil, dir, defaultFlushDeadline, nil)
366366
defer s.Close()
367367

368368
cfg := config.DefaultQueueConfig

storage/remote/read_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func TestNoDuplicateReadConfigs(t *testing.T) {
9393

9494
for _, tc := range cases {
9595
t.Run("", func(t *testing.T) {
96-
s := NewStorage(nil, nil, nil, dir, defaultFlushDeadline, nil, false)
96+
s := NewStorage(nil, nil, nil, dir, defaultFlushDeadline, nil)
9797
conf := &config.Config{
9898
GlobalConfig: config.DefaultGlobalConfig,
9999
RemoteReadConfigs: tc.cfgs,

storage/remote/storage.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ type Storage struct {
6464
}
6565

6666
// NewStorage returns a remote.Storage.
67-
func NewStorage(l *slog.Logger, reg prometheus.Registerer, stCallback startTimeCallback, walDir string, flushDeadline time.Duration, sm ReadyScrapeManager, metadataInWAL bool) *Storage {
67+
func NewStorage(l *slog.Logger, reg prometheus.Registerer, stCallback startTimeCallback, walDir string, flushDeadline time.Duration, sm ReadyScrapeManager) *Storage {
6868
if l == nil {
6969
l = promslog.NewNopLogger()
7070
}
@@ -76,7 +76,7 @@ func NewStorage(l *slog.Logger, reg prometheus.Registerer, stCallback startTimeC
7676
deduper: deduper,
7777
localStartTimeCallback: stCallback,
7878
}
79-
s.rws = NewWriteStorage(s.logger, reg, walDir, flushDeadline, sm, metadataInWAL)
79+
s.rws = NewWriteStorage(s.logger, reg, walDir, flushDeadline, sm)
8080
return s
8181
}
8282

storage/remote/storage_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
func TestStorageLifecycle(t *testing.T) {
3030
dir := t.TempDir()
3131

32-
s := NewStorage(nil, nil, nil, dir, defaultFlushDeadline, nil, false)
32+
s := NewStorage(nil, nil, nil, dir, defaultFlushDeadline, nil)
3333
conf := &config.Config{
3434
GlobalConfig: config.DefaultGlobalConfig,
3535
RemoteWriteConfigs: []*config.RemoteWriteConfig{
@@ -56,7 +56,7 @@ func TestStorageLifecycle(t *testing.T) {
5656
func TestUpdateRemoteReadConfigs(t *testing.T) {
5757
dir := t.TempDir()
5858

59-
s := NewStorage(nil, nil, nil, dir, defaultFlushDeadline, nil, false)
59+
s := NewStorage(nil, nil, nil, dir, defaultFlushDeadline, nil)
6060

6161
conf := &config.Config{
6262
GlobalConfig: config.GlobalConfig{},
@@ -77,7 +77,7 @@ func TestUpdateRemoteReadConfigs(t *testing.T) {
7777
func TestFilterExternalLabels(t *testing.T) {
7878
dir := t.TempDir()
7979

80-
s := NewStorage(nil, nil, nil, dir, defaultFlushDeadline, nil, false)
80+
s := NewStorage(nil, nil, nil, dir, defaultFlushDeadline, nil)
8181

8282
conf := &config.Config{
8383
GlobalConfig: config.GlobalConfig{
@@ -102,7 +102,7 @@ func TestFilterExternalLabels(t *testing.T) {
102102
func TestIgnoreExternalLabels(t *testing.T) {
103103
dir := t.TempDir()
104104

105-
s := NewStorage(nil, nil, nil, dir, defaultFlushDeadline, nil, false)
105+
s := NewStorage(nil, nil, nil, dir, defaultFlushDeadline, nil)
106106

107107
conf := &config.Config{
108108
GlobalConfig: config.GlobalConfig{
@@ -154,7 +154,7 @@ func baseRemoteReadConfig(host string) *config.RemoteReadConfig {
154154
// ApplyConfig runs concurrently with Notify
155155
// See https://github.com/prometheus/prometheus/issues/12747
156156
func TestWriteStorageApplyConfigsDuringCommit(t *testing.T) {
157-
s := NewStorage(nil, nil, nil, t.TempDir(), defaultFlushDeadline, nil, false)
157+
s := NewStorage(nil, nil, nil, t.TempDir(), defaultFlushDeadline, nil)
158158

159159
var wg sync.WaitGroup
160160
wg.Add(2000)

storage/remote/write.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ package remote
1515

1616
import (
1717
"context"
18-
"errors"
1918
"fmt"
2019
"log/slog"
2120
"math"
@@ -67,7 +66,6 @@ type WriteStorage struct {
6766
externalLabels labels.Labels
6867
dir string
6968
queues map[string]*QueueManager
70-
metadataInWAL bool
7169
samplesIn *ewmaRate
7270
flushDeadline time.Duration
7371
interner *pool
@@ -79,7 +77,7 @@ type WriteStorage struct {
7977
}
8078

8179
// NewWriteStorage creates and runs a WriteStorage.
82-
func NewWriteStorage(logger *slog.Logger, reg prometheus.Registerer, dir string, flushDeadline time.Duration, sm ReadyScrapeManager, metadataInWal bool) *WriteStorage {
80+
func NewWriteStorage(logger *slog.Logger, reg prometheus.Registerer, dir string, flushDeadline time.Duration, sm ReadyScrapeManager) *WriteStorage {
8381
if logger == nil {
8482
logger = promslog.NewNopLogger()
8583
}
@@ -95,7 +93,6 @@ func NewWriteStorage(logger *slog.Logger, reg prometheus.Registerer, dir string,
9593
interner: newPool(),
9694
scraper: sm,
9795
quit: make(chan struct{}),
98-
metadataInWAL: metadataInWal,
9996
highestTimestamp: &maxTimestamp{
10097
Gauge: prometheus.NewGauge(prometheus.GaugeOpts{
10198
Namespace: namespace,
@@ -149,9 +146,6 @@ func (rws *WriteStorage) ApplyConfig(conf *config.Config) error {
149146
newQueues := make(map[string]*QueueManager)
150147
newHashes := []string{}
151148
for _, rwConf := range conf.RemoteWriteConfigs {
152-
if rwConf.ProtobufMessage == config.RemoteWriteProtoMsgV2 && !rws.metadataInWAL {
153-
return errors.New("invalid remote write configuration, if you are using remote write version 2.0 the `--enable-feature=metadata-wal-records` feature flag must be enabled")
154-
}
155149
hash, err := toHash(rwConf)
156150
if err != nil {
157151
return err

storage/remote/write_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func TestWriteStorageApplyConfig_NoDuplicateWriteConfigs(t *testing.T) {
117117
},
118118
} {
119119
t.Run("", func(t *testing.T) {
120-
s := NewWriteStorage(nil, nil, dir, time.Millisecond, nil, false)
120+
s := NewWriteStorage(nil, nil, dir, time.Millisecond, nil)
121121
conf := &config.Config{
122122
GlobalConfig: config.DefaultGlobalConfig,
123123
RemoteWriteConfigs: tc.cfgs,
@@ -143,7 +143,7 @@ func TestWriteStorageApplyConfig_RestartOnNameChange(t *testing.T) {
143143
hash, err := toHash(cfg)
144144
require.NoError(t, err)
145145

146-
s := NewWriteStorage(nil, nil, dir, time.Millisecond, nil, false)
146+
s := NewWriteStorage(nil, nil, dir, time.Millisecond, nil)
147147

148148
conf := &config.Config{
149149
GlobalConfig: config.DefaultGlobalConfig,
@@ -165,7 +165,7 @@ func TestWriteStorageApplyConfig_RestartOnNameChange(t *testing.T) {
165165
func TestWriteStorageApplyConfig_UpdateWithRegisterer(t *testing.T) {
166166
dir := t.TempDir()
167167

168-
s := NewWriteStorage(nil, prometheus.NewRegistry(), dir, time.Millisecond, nil, false)
168+
s := NewWriteStorage(nil, prometheus.NewRegistry(), dir, time.Millisecond, nil)
169169
c1 := &config.RemoteWriteConfig{
170170
Name: "named",
171171
URL: &common_config.URL{
@@ -206,7 +206,7 @@ func TestWriteStorageApplyConfig_UpdateWithRegisterer(t *testing.T) {
206206
func TestWriteStorageApplyConfig_Lifecycle(t *testing.T) {
207207
dir := t.TempDir()
208208

209-
s := NewWriteStorage(nil, nil, dir, defaultFlushDeadline, nil, false)
209+
s := NewWriteStorage(nil, nil, dir, defaultFlushDeadline, nil)
210210
conf := &config.Config{
211211
GlobalConfig: config.DefaultGlobalConfig,
212212
RemoteWriteConfigs: []*config.RemoteWriteConfig{
@@ -222,7 +222,7 @@ func TestWriteStorageApplyConfig_Lifecycle(t *testing.T) {
222222
func TestWriteStorageApplyConfig_UpdateExternalLabels(t *testing.T) {
223223
dir := t.TempDir()
224224

225-
s := NewWriteStorage(nil, prometheus.NewRegistry(), dir, time.Second, nil, false)
225+
s := NewWriteStorage(nil, prometheus.NewRegistry(), dir, time.Second, nil)
226226

227227
externalLabels := labels.FromStrings("external", "true")
228228
conf := &config.Config{
@@ -250,7 +250,7 @@ func TestWriteStorageApplyConfig_UpdateExternalLabels(t *testing.T) {
250250
func TestWriteStorageApplyConfig_Idempotent(t *testing.T) {
251251
dir := t.TempDir()
252252

253-
s := NewWriteStorage(nil, nil, dir, defaultFlushDeadline, nil, false)
253+
s := NewWriteStorage(nil, nil, dir, defaultFlushDeadline, nil)
254254
conf := &config.Config{
255255
GlobalConfig: config.GlobalConfig{},
256256
RemoteWriteConfigs: []*config.RemoteWriteConfig{
@@ -274,7 +274,7 @@ func TestWriteStorageApplyConfig_Idempotent(t *testing.T) {
274274
func TestWriteStorageApplyConfig_PartialUpdate(t *testing.T) {
275275
dir := t.TempDir()
276276

277-
s := NewWriteStorage(nil, nil, dir, defaultFlushDeadline, nil, false)
277+
s := NewWriteStorage(nil, nil, dir, defaultFlushDeadline, nil)
278278

279279
c0 := &config.RemoteWriteConfig{
280280
RemoteTimeout: model.Duration(10 * time.Second),

tsdb/agent/db_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func createTestAgentDB(t testing.TB, reg prometheus.Registerer, opts *Options) *
9191
t.Helper()
9292

9393
dbDir := t.TempDir()
94-
rs := remote.NewStorage(promslog.NewNopLogger(), reg, startTime, dbDir, time.Second*30, nil, false)
94+
rs := remote.NewStorage(promslog.NewNopLogger(), reg, startTime, dbDir, time.Second*30, nil)
9595
t.Cleanup(func() {
9696
require.NoError(t, rs.Close())
9797
})
@@ -737,7 +737,7 @@ func TestLockfile(t *testing.T) {
737737
tsdbutil.TestDirLockerUsage(t, func(t *testing.T, data string, createLock bool) (*tsdbutil.DirLocker, testutil.Closer) {
738738
logger := promslog.NewNopLogger()
739739
reg := prometheus.NewRegistry()
740-
rs := remote.NewStorage(logger, reg, startTime, data, time.Second*30, nil, false)
740+
rs := remote.NewStorage(logger, reg, startTime, data, time.Second*30, nil)
741741
t.Cleanup(func() {
742742
require.NoError(t, rs.Close())
743743
})
@@ -757,7 +757,7 @@ func TestLockfile(t *testing.T) {
757757

758758
func Test_ExistingWAL_NextRef(t *testing.T) {
759759
dbDir := t.TempDir()
760-
rs := remote.NewStorage(promslog.NewNopLogger(), nil, startTime, dbDir, time.Second*30, nil, false)
760+
rs := remote.NewStorage(promslog.NewNopLogger(), nil, startTime, dbDir, time.Second*30, nil)
761761
defer func() {
762762
require.NoError(t, rs.Close())
763763
}()

web/api/v1/api_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ func TestEndpoints(t *testing.T) {
495495

496496
remote := remote.NewStorage(promslog.New(&promslogConfig), prometheus.DefaultRegisterer, func() (int64, error) {
497497
return 0, nil
498-
}, dbDir, 1*time.Second, nil, false)
498+
}, dbDir, 1*time.Second, nil)
499499

500500
err = remote.ApplyConfig(&config.Config{
501501
RemoteReadConfigs: []*config.RemoteReadConfig{

0 commit comments

Comments
 (0)