@@ -154,21 +154,21 @@ func init() {
154
154
// serverOnlyFlag creates server-only kingpin flag.
155
155
func serverOnlyFlag (app * kingpin.Application , name , help string ) * kingpin.FlagClause {
156
156
return app .Flag (name , fmt .Sprintf ("%s Use with server mode only." , help )).
157
- PreAction (func (parseContext * kingpin.ParseContext ) error {
158
- // This will be invoked only if flag is actually provided by user.
159
- serverOnlyFlags = append (serverOnlyFlags , "--" + name )
160
- return nil
161
- })
157
+ PreAction (func (parseContext * kingpin.ParseContext ) error {
158
+ // This will be invoked only if flag is actually provided by user.
159
+ serverOnlyFlags = append (serverOnlyFlags , "--" + name )
160
+ return nil
161
+ })
162
162
}
163
163
164
164
// agentOnlyFlag creates agent-only kingpin flag.
165
165
func agentOnlyFlag (app * kingpin.Application , name , help string ) * kingpin.FlagClause {
166
166
return app .Flag (name , fmt .Sprintf ("%s Use with agent mode only." , help )).
167
- PreAction (func (parseContext * kingpin.ParseContext ) error {
168
- // This will be invoked only if flag is actually provided by user.
169
- agentOnlyFlags = append (agentOnlyFlags , "--" + name )
170
- return nil
171
- })
167
+ PreAction (func (parseContext * kingpin.ParseContext ) error {
168
+ // This will be invoked only if flag is actually provided by user.
169
+ agentOnlyFlags = append (agentOnlyFlags , "--" + name )
170
+ return nil
171
+ })
172
172
}
173
173
174
174
type flagConfig struct {
@@ -427,6 +427,9 @@ func main() {
427
427
serverOnlyFlag (a , "storage.tsdb.wal-compression-type" , "Compression algorithm for the tsdb WAL." ).
428
428
Hidden ().Default (string (wlog .CompressionSnappy )).EnumVar (& cfg .tsdb .WALCompressionType , string (wlog .CompressionSnappy ), string (wlog .CompressionZstd ))
429
429
430
+ serverOnlyFlag (a , "storage.tsdb.wal-version" , fmt .Sprintf ("Version for the new WAL segments. Supported versions: %v" , wlog .ReleasedSupportedSegmentVersions ())).
431
+ Default (fmt .Sprintf ("%v" , wlog .DefaultSegmentVersion )).Uint32Var (& cfg .tsdb .WALSegmentVersion )
432
+
430
433
serverOnlyFlag (a , "storage.tsdb.head-chunks-write-queue-size" , "Size of the queue through which head chunks are written to the disk to be m-mapped, 0 disables the queue completely. Experimental." ).
431
434
Default ("0" ).IntVar (& cfg .tsdb .HeadChunksWriteQueueSize )
432
435
@@ -443,12 +446,15 @@ func main() {
443
446
"Size at which to split WAL segment files. Example: 100MB" ).
444
447
Hidden ().PlaceHolder ("<bytes>" ).BytesVar (& cfg .agent .WALSegmentSize )
445
448
446
- agentOnlyFlag (a , "storage.agent.wal-compression" , "Compress the agent WAL." ).
449
+ agentOnlyFlag (a , "storage.agent.wal-compression" , "Compress the new WAL segments ." ).
447
450
Default ("true" ).BoolVar (& cfg .agent .WALCompression )
448
451
449
452
agentOnlyFlag (a , "storage.agent.wal-compression-type" , "Compression algorithm for the agent WAL." ).
450
453
Hidden ().Default (string (wlog .CompressionSnappy )).EnumVar (& cfg .agent .WALCompressionType , string (wlog .CompressionSnappy ), string (wlog .CompressionZstd ))
451
454
455
+ agentOnlyFlag (a , "storage.agent.wal-version" , fmt .Sprintf ("Version for the new WAL segments. Supported versions: %v" , wlog .ReleasedSupportedSegmentVersions ())).
456
+ Default (fmt .Sprintf ("%v" , wlog .DefaultSegmentVersion )).Uint32Var (& cfg .agent .WALSegmentVersion )
457
+
452
458
agentOnlyFlag (a , "storage.agent.wal-truncate-frequency" ,
453
459
"The frequency at which to truncate the WAL and remove old data." ).
454
460
Hidden ().PlaceHolder ("<duration>" ).SetValue (& cfg .agent .TruncateFrequency )
@@ -1229,6 +1235,10 @@ func main() {
1229
1235
g .Add (
1230
1236
func () error {
1231
1237
logger .Info ("Starting TSDB ..." )
1238
+ if ! wlog .SegmentVersion (cfg .tsdb .WALSegmentVersion ).IsReleased () {
1239
+ return fmt .Errorf ("flag 'storage.tsdb.wal-version' was set to unsupported WAL segment version %v; supported versions %v" , cfg .tsdb .WALSegmentVersion , wlog .ReleasedSupportedSegmentVersions ())
1240
+ }
1241
+
1232
1242
if cfg .tsdb .WALSegmentSize != 0 {
1233
1243
if cfg .tsdb .WALSegmentSize < 10 * 1024 * 1024 || cfg .tsdb .WALSegmentSize > 256 * 1024 * 1024 {
1234
1244
return errors .New ("flag 'storage.tsdb.wal-segment-size' must be set between 10MB and 256MB" )
@@ -1285,6 +1295,10 @@ func main() {
1285
1295
g .Add (
1286
1296
func () error {
1287
1297
logger .Info ("Starting WAL storage ..." )
1298
+ if ! wlog .SegmentVersion (cfg .agent .WALSegmentVersion ).IsReleased () {
1299
+ return fmt .Errorf ("flag 'storage.agent.wal-version' was set to unsupported WAL segment version %v; supported versions %v" , cfg .tsdb .WALSegmentVersion , wlog .ReleasedSupportedSegmentVersions ())
1300
+ }
1301
+
1288
1302
if cfg .agent .WALSegmentSize != 0 {
1289
1303
if cfg .agent .WALSegmentSize < 10 * 1024 * 1024 || cfg .agent .WALSegmentSize > 256 * 1024 * 1024 {
1290
1304
return errors .New ("flag 'storage.agent.wal-segment-size' must be set between 10MB and 256MB" )
@@ -1492,7 +1506,7 @@ func reloadConfig(filename string, enableExemplarStorage bool, logger *slog.Logg
1492
1506
1493
1507
func startsOrEndsWithQuote (s string ) bool {
1494
1508
return strings .HasPrefix (s , "\" " ) || strings .HasPrefix (s , "'" ) ||
1495
- strings .HasSuffix (s , "\" " ) || strings .HasSuffix (s , "'" )
1509
+ strings .HasSuffix (s , "\" " ) || strings .HasSuffix (s , "'" )
1496
1510
}
1497
1511
1498
1512
// compileCORSRegexString compiles given string and adds anchors.
@@ -1780,6 +1794,7 @@ func (rm *readyScrapeManager) Get() (*scrape.Manager, error) {
1780
1794
// This is required as tsdb.Option fields are unit agnostic (time).
1781
1795
type tsdbOptions struct {
1782
1796
WALSegmentSize units.Base2Bytes
1797
+ WALSegmentVersion uint32
1783
1798
MaxBlockChunkSegmentSize units.Base2Bytes
1784
1799
RetentionDuration model.Duration
1785
1800
MaxBytes units.Base2Bytes
@@ -1804,12 +1819,15 @@ type tsdbOptions struct {
1804
1819
1805
1820
func (opts tsdbOptions ) ToTSDBOptions () tsdb.Options {
1806
1821
return tsdb.Options {
1807
- WALSegmentSize : int (opts .WALSegmentSize ),
1822
+ WALSegment : wlog.SegmentOptions {
1823
+ Version : wlog .SegmentVersion (opts .WALSegmentVersion ),
1824
+ Compression : wlog .ParseCompressionType (opts .WALCompression , opts .WALCompressionType ),
1825
+ Size : int (opts .WALSegmentSize ),
1826
+ },
1808
1827
MaxBlockChunkSegmentSize : int64 (opts .MaxBlockChunkSegmentSize ),
1809
1828
RetentionDuration : int64 (time .Duration (opts .RetentionDuration ) / time .Millisecond ),
1810
1829
MaxBytes : int64 (opts .MaxBytes ),
1811
1830
NoLockfile : opts .NoLockfile ,
1812
- WALCompression : wlog .ParseCompressionType (opts .WALCompression , opts .WALCompressionType ),
1813
1831
HeadChunksWriteQueueSize : opts .HeadChunksWriteQueueSize ,
1814
1832
SamplesPerChunk : opts .SamplesPerChunk ,
1815
1833
StripeSize : opts .StripeSize ,
@@ -1833,6 +1851,7 @@ type agentOptions struct {
1833
1851
WALSegmentSize units.Base2Bytes
1834
1852
WALCompression bool
1835
1853
WALCompressionType string
1854
+ WALSegmentVersion uint32
1836
1855
StripeSize int
1837
1856
TruncateFrequency model.Duration
1838
1857
MinWALTime , MaxWALTime model.Duration
@@ -1845,8 +1864,11 @@ func (opts agentOptions) ToAgentOptions(outOfOrderTimeWindow int64) agent.Option
1845
1864
outOfOrderTimeWindow = 0
1846
1865
}
1847
1866
return agent.Options {
1848
- WALSegmentSize : int (opts .WALSegmentSize ),
1849
- WALCompression : wlog .ParseCompressionType (opts .WALCompression , opts .WALCompressionType ),
1867
+ WALSegment : wlog.SegmentOptions {
1868
+ Version : wlog .SegmentVersion (opts .WALSegmentVersion ),
1869
+ Compression : wlog .ParseCompressionType (opts .WALCompression , opts .WALCompressionType ),
1870
+ Size : int (opts .WALSegmentSize ),
1871
+ },
1850
1872
StripeSize : opts .StripeSize ,
1851
1873
TruncateFrequency : time .Duration (opts .TruncateFrequency ),
1852
1874
MinWALTime : durationToInt64Millis (time .Duration (opts .MinWALTime )),
0 commit comments