From 4741c3969409e63634c200fbf82376853d94799e Mon Sep 17 00:00:00 2001 From: Jarema Date: Tue, 22 Oct 2024 13:41:15 +0200 Subject: [PATCH] Add Stream subjects count Signed-off-by: Jarema --- collector/jsz.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/collector/jsz.go b/collector/jsz.go index 7da6b2d..a9271b7 100644 --- a/collector/jsz.go +++ b/collector/jsz.go @@ -45,6 +45,7 @@ type jszCollector struct { streamFirstSeq *prometheus.Desc streamLastSeq *prometheus.Desc streamConsumerCount *prometheus.Desc + streamSubjectCount *prometheus.Desc // Consumer stats consumerDeliveredConsumerSeq *prometheus.Desc @@ -168,6 +169,13 @@ func newJszCollector(system, endpoint string, servers []*CollectedServer) promet streamLabels, nil, ), + // jetstream_stream_subjects + streamSubjectCount: prometheus.NewDesc( + prometheus.BuildFQName(system, "stream", "subject_count"), + "Total number of subjects in a stream", + streamLabels, + nil, + ), // jetstream_consumer_delivered_consumer_seq consumerDeliveredConsumerSeq: prometheus.NewDesc( prometheus.BuildFQName(system, "consumer", "delivered_consumer_seq"), @@ -253,6 +261,7 @@ func (nc *jszCollector) Describe(ch chan<- *prometheus.Desc) { ch <- nc.streamFirstSeq ch <- nc.streamLastSeq ch <- nc.streamConsumerCount + ch <- nc.streamSubjectCount // Consumer state ch <- nc.consumerDeliveredConsumerSeq @@ -354,6 +363,7 @@ func (nc *jszCollector) Collect(ch chan<- prometheus.Metric) { ch <- streamMetric(nc.streamFirstSeq, float64(stream.State.FirstSeq)) ch <- streamMetric(nc.streamLastSeq, float64(stream.State.LastSeq)) ch <- streamMetric(nc.streamConsumerCount, float64(stream.State.Consumers)) + ch <- streamMetric(nc.streamSubjectCount, float64(stream.State.NumSubjects)) // Now with the consumers. for _, consumer := range stream.Consumer {