Skip to content

Commit

Permalink
Add Stream subjects count
Browse files Browse the repository at this point in the history
Signed-off-by: Jarema <[email protected]>
  • Loading branch information
Jarema committed Oct 22, 2024
1 parent 814c252 commit 4741c39
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions collector/jsz.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type jszCollector struct {
streamFirstSeq *prometheus.Desc
streamLastSeq *prometheus.Desc
streamConsumerCount *prometheus.Desc
streamSubjectCount *prometheus.Desc

// Consumer stats
consumerDeliveredConsumerSeq *prometheus.Desc
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 4741c39

Please sign in to comment.