Skip to content

Commit ab31fc0

Browse files
committed
EOSOPS-766: monitor EOS MGM namespace cache hit rates
1 parent cab6c9d commit ab31fc0

File tree

2 files changed

+77
-1
lines changed

2 files changed

+77
-1
lines changed

collector/ns.go

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"log"
66
"strconv"
77

8-
"github.com/prometheus/client_golang/prometheus"
98
"github.com/cern-eos/eos_exporter/eosclient"
9+
"github.com/prometheus/client_golang/prometheus"
1010

1111
//"os"
1212
//"bufio"
@@ -54,6 +54,10 @@ type NSCollector struct {
5454
Total_files_changelog_avg_entry_size *prometheus.GaugeVec
5555
Total_files_changelog_size *prometheus.GaugeVec
5656
Uptime *prometheus.GaugeVec
57+
Cache_files_requests *prometheus.GaugeVec
58+
Cache_files_hits *prometheus.GaugeVec
59+
Cache_containers_requests *prometheus.GaugeVec
60+
Cache_containers_hits *prometheus.GaugeVec
5761
}
5862

5963
type NSActivityCollector struct {
@@ -430,6 +434,42 @@ func NewNSCollector(opts *CollectorOpts) *NSCollector {
430434
},
431435
[]string{},
432436
),
437+
Cache_files_requests: prometheus.NewGaugeVec(
438+
prometheus.GaugeOpts{
439+
Namespace: namespace,
440+
Name: "ns_cache_files_requests_total",
441+
Help: "Cache_files_requests: Number of cache file requests.",
442+
ConstLabels: labels,
443+
},
444+
[]string{},
445+
),
446+
Cache_files_hits: prometheus.NewGaugeVec(
447+
prometheus.GaugeOpts{
448+
Namespace: namespace,
449+
Name: "ns_cache_files_hits_total",
450+
Help: "Cache_files_hits: Number of cache file hits.",
451+
ConstLabels: labels,
452+
},
453+
[]string{},
454+
),
455+
Cache_containers_requests: prometheus.NewGaugeVec(
456+
prometheus.GaugeOpts{
457+
Namespace: namespace,
458+
Name: "ns_cache_container_requests_total",
459+
Help: "Cache_container_requests: Number of cache container requests.",
460+
ConstLabels: labels,
461+
},
462+
[]string{},
463+
),
464+
Cache_containers_hits: prometheus.NewGaugeVec(
465+
prometheus.GaugeOpts{
466+
Namespace: namespace,
467+
Name: "ns_cache_container_hits_total",
468+
Help: "Cache_container_hits: Number of cache container hits.",
469+
ConstLabels: labels,
470+
},
471+
[]string{},
472+
),
433473
Hanging_since: prometheus.NewGaugeVec(
434474
prometheus.GaugeOpts{
435475
Namespace: namespace,
@@ -595,6 +635,10 @@ func (o *NSCollector) collectorList() []prometheus.Collector {
595635
o.Total_files_changelog_avg_entry_size,
596636
o.Total_files_changelog_size,
597637
o.Uptime,
638+
o.Cache_files_requests,
639+
o.Cache_files_hits,
640+
o.Cache_containers_requests,
641+
o.Cache_containers_hits,
598642
}
599643
}
600644

@@ -915,6 +959,30 @@ func (o *NSCollector) collectNSDF() error {
915959
if err == nil {
916960
o.Hanging_since.WithLabelValues().Set(hanging_since)
917961
}
962+
963+
// Cache_files_requests
964+
cache_files_requests, err := strconv.ParseFloat(m.Cache_files_requests, 64)
965+
if err == nil {
966+
o.Cache_files_requests.WithLabelValues().Set(cache_files_requests)
967+
}
968+
969+
// Cache_files_hits
970+
cache_files_hits, err := strconv.ParseFloat(m.Cache_files_hits, 64)
971+
if err == nil {
972+
o.Cache_files_hits.WithLabelValues().Set(cache_files_hits)
973+
}
974+
975+
// Cache_containers_requests
976+
cache_containers_requests, err := strconv.ParseFloat(m.Cache_containers_requests, 64)
977+
if err == nil {
978+
o.Cache_containers_requests.WithLabelValues().Set(cache_containers_requests)
979+
}
980+
981+
// Cache_containers_hits
982+
cache_containers_hits, err := strconv.ParseFloat(m.Cache_containers_hits, 64)
983+
if err == nil {
984+
o.Cache_containers_hits.WithLabelValues().Set(cache_containers_hits)
985+
}
918986
}
919987

920988
return nil

eosclient/eos.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ type NSInfo struct {
221221
Total_files_changelog_avg_entry_size string
222222
Total_files_changelog_size string
223223
Uptime string
224+
Cache_files_requests string
225+
Cache_files_hits string
226+
Cache_containers_requests string
227+
Cache_containers_hits string
224228
}
225229

226230
type NSActivityInfo struct {
@@ -859,6 +863,10 @@ func (c *Client) parseNSsInfo(raw string, raw_batch string, ctx context.Context)
859863
kv["ns.total.files.changelog.avg_entry_size"],
860864
kv["ns.total.files.changelog.size"],
861865
kv["ns.uptime"],
866+
kv["ns.cache.files.requests"],
867+
kv["ns.cache.files.hits"],
868+
kv["ns.cache.containers.requests"],
869+
kv["ns.cache.containers.hits"],
862870
}
863871
}
864872
}

0 commit comments

Comments
 (0)