@@ -169,12 +169,14 @@ type WAL struct {
169169 compress bool
170170 snappyBuf []byte
171171
172- fsyncDuration prometheus.Summary
173- pageFlushes prometheus.Counter
174- pageCompletions prometheus.Counter
175- truncateFail prometheus.Counter
176- truncateTotal prometheus.Counter
177- currentSegment prometheus.Gauge
172+ fsyncDuration prometheus.Summary
173+ pageFlushes prometheus.Counter
174+ pageCompletions prometheus.Counter
175+ truncateFail prometheus.Counter
176+ truncateTotal prometheus.Counter
177+ currentSegment prometheus.Gauge
178+ recordRawSize prometheus.Counter
179+ recordCompressedSize prometheus.Counter
178180}
179181
180182// New returns a new WAL over the given directory.
@@ -227,8 +229,16 @@ func NewSize(logger log.Logger, reg prometheus.Registerer, dir string, segmentSi
227229 Name : "prometheus_tsdb_wal_segment_current" ,
228230 Help : "WAL segment index that TSDB is currently writing to." ,
229231 })
232+ w .recordRawSize = prometheus .NewCounter (prometheus.CounterOpts {
233+ Name : "prometheus_tsdb_wal_raw_record_bytes_total" ,
234+ Help : "The total number of bytes received by the WAL." ,
235+ })
236+ w .recordCompressedSize = prometheus .NewCounter (prometheus.CounterOpts {
237+ Name : "prometheus_tsdb_wal_compressed_record_bytes_total" ,
238+ Help : "The total size of records after having been compressed." ,
239+ })
230240 if reg != nil {
231- reg .MustRegister (w .fsyncDuration , w .pageFlushes , w .pageCompletions , w .truncateFail , w .truncateTotal , w .currentSegment )
241+ reg .MustRegister (w .fsyncDuration , w .pageFlushes , w .pageCompletions , w .truncateFail , w .truncateTotal , w .currentSegment , w . recordRawSize , w . recordCompressedSize )
232242 }
233243
234244 _ , j , err := w .Segments ()
@@ -560,6 +570,7 @@ func (w *WAL) log(rec []byte, final bool) error {
560570 }
561571
562572 compressed := false
573+ w .recordRawSize .Add (float64 (len (rec )))
563574 if w .compress && len (rec ) > 0 {
564575 // The snappy library uses `len` to calculate if we need a new buffer.
565576 // In order to allocate as few buffers as possible make the length
@@ -571,6 +582,7 @@ func (w *WAL) log(rec []byte, final bool) error {
571582 compressed = true
572583 }
573584 }
585+ w .recordCompressedSize .Add (float64 (len (rec )))
574586
575587 // Populate as many pages as necessary to fit the record.
576588 // Be careful to always do one pass to ensure we write zero-length records.
0 commit comments