1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
10 "github.com/prometheus/client_golang/prometheus"
13 type nodeMetrics struct {
14 reg *prometheus.Registry
17 func (m *nodeMetrics) setupBufferPoolMetrics(b *bufferPool) {
18 m.reg.MustRegister(prometheus.NewGaugeFunc(
21 Subsystem: "keepstore",
22 Name: "bufferpool_allocated_bytes",
23 Help: "Number of bytes allocated to buffers",
25 func() float64 { return float64(b.Alloc()) },
27 m.reg.MustRegister(prometheus.NewGaugeFunc(
30 Subsystem: "keepstore",
31 Name: "bufferpool_max_buffers",
32 Help: "Maximum number of buffers allowed",
34 func() float64 { return float64(b.Cap()) },
36 m.reg.MustRegister(prometheus.NewGaugeFunc(
39 Subsystem: "keepstore",
40 Name: "bufferpool_inuse_buffers",
41 Help: "Number of buffers in use",
43 func() float64 { return float64(b.Len()) },
47 func (m *nodeMetrics) setupWorkQueueMetrics(q *WorkQueue, qName string) {
48 m.reg.MustRegister(prometheus.NewGaugeFunc(
51 Subsystem: "keepstore",
52 Name: fmt.Sprintf("%s_queue_inprogress_entries", qName),
53 Help: fmt.Sprintf("Number of %s requests in progress", qName),
55 func() float64 { return float64(getWorkQueueStatus(q).InProgress) },
57 m.reg.MustRegister(prometheus.NewGaugeFunc(
60 Subsystem: "keepstore",
61 Name: fmt.Sprintf("%s_queue_pending_entries", qName),
62 Help: fmt.Sprintf("Number of queued %s requests", qName),
64 func() float64 { return float64(getWorkQueueStatus(q).Queued) },
68 type volumeMetricsVecs struct {
69 ioBytes *prometheus.CounterVec
70 errCounters *prometheus.CounterVec
71 opsCounters *prometheus.CounterVec
74 func newVolumeMetricsVecs(reg *prometheus.Registry) *volumeMetricsVecs {
75 m := &volumeMetricsVecs{}
76 m.opsCounters = prometheus.NewCounterVec(
77 prometheus.CounterOpts{
79 Subsystem: "keepstore",
80 Name: "volume_operations",
81 Help: "Number of volume operations",
83 []string{"device_id", "operation"},
85 reg.MustRegister(m.opsCounters)
86 m.errCounters = prometheus.NewCounterVec(
87 prometheus.CounterOpts{
89 Subsystem: "keepstore",
90 Name: "volume_errors",
91 Help: "Number of volume errors",
93 []string{"device_id", "error_type"},
95 reg.MustRegister(m.errCounters)
96 m.ioBytes = prometheus.NewCounterVec(
97 prometheus.CounterOpts{
99 Subsystem: "keepstore",
100 Name: "volume_io_bytes",
101 Help: "Volume I/O traffic in bytes",
103 []string{"device_id", "direction"},
105 reg.MustRegister(m.ioBytes)
110 func (vm *volumeMetricsVecs) getCounterVecsFor(lbls prometheus.Labels) (opsCV, errCV, ioCV *prometheus.CounterVec) {
111 opsCV = vm.opsCounters.MustCurryWith(lbls)
112 errCV = vm.errCounters.MustCurryWith(lbls)
113 ioCV = vm.ioBytes.MustCurryWith(lbls)