@@ -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 ()
@@ -552,6 +562,7 @@ func (w *WAL) log(rec []byte, final bool) error {
552562 }
553563
554564 compressed := false
565+ w .recordRawSize .Add (float64 (len (rec )))
555566 if w .compress && len (rec ) > 0 {
556567 // Allow Snappy to use the full capacity of the buffer.
557568 w .snappyBuf = w .snappyBuf [:cap (w .snappyBuf )]
@@ -561,6 +572,7 @@ func (w *WAL) log(rec []byte, final bool) error {
561572 compressed = true
562573 }
563574 }
575+ w .recordCompressedSize .Add (float64 (len (rec )))
564576
565577 // Populate as many pages as necessary to fit the record.
566578 // Be careful to always do one pass to ensure we write zero-length records.
0 commit comments