mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-20 07:19:17 +01:00
lib/persistentqueue: add vm_persistentqueue_bytes_pending
metric (#619)
Metric `vm_persistentqueue_bytes_pending` is a gauge that shows current amount of bytes in persistentqueue flushed on disk as a difference between write and read offsets. This metric is very similar to `vmagent_remotewrite_pending_data_bytes` except of accounting for bytes in-memory.
This commit is contained in:
parent
a02097e657
commit
605711bde5
@ -62,6 +62,8 @@ type Queue struct {
|
|||||||
|
|
||||||
blocksRead *metrics.Counter
|
blocksRead *metrics.Counter
|
||||||
bytesRead *metrics.Counter
|
bytesRead *metrics.Counter
|
||||||
|
|
||||||
|
bytesPending *metrics.Gauge
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResetIfEmpty resets q if it is empty.
|
// ResetIfEmpty resets q if it is empty.
|
||||||
@ -166,6 +168,9 @@ func tryOpeningQueue(path, name string, chunkFileSize, maxBlockSize, maxPendingB
|
|||||||
q.bytesWritten = metrics.GetOrCreateCounter(fmt.Sprintf(`vm_persistentqueue_bytes_written_total{path=%q}`, path))
|
q.bytesWritten = metrics.GetOrCreateCounter(fmt.Sprintf(`vm_persistentqueue_bytes_written_total{path=%q}`, path))
|
||||||
q.blocksRead = metrics.GetOrCreateCounter(fmt.Sprintf(`vm_persistentqueue_blocks_read_total{path=%q}`, path))
|
q.blocksRead = metrics.GetOrCreateCounter(fmt.Sprintf(`vm_persistentqueue_blocks_read_total{path=%q}`, path))
|
||||||
q.bytesRead = metrics.GetOrCreateCounter(fmt.Sprintf(`vm_persistentqueue_bytes_read_total{path=%q}`, path))
|
q.bytesRead = metrics.GetOrCreateCounter(fmt.Sprintf(`vm_persistentqueue_bytes_read_total{path=%q}`, path))
|
||||||
|
q.bytesPending = metrics.GetOrCreateGauge(fmt.Sprintf(`vm_persistentqueue_bytes_pending{path=%q}`, path), func() float64 {
|
||||||
|
return float64(q.GetPendingBytes())
|
||||||
|
})
|
||||||
|
|
||||||
cleanOnError := func() {
|
cleanOnError := func() {
|
||||||
if q.reader != nil {
|
if q.reader != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user