Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Stream subjects count #314

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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