Skip to content

Commit 6da52cd

Browse files
authored
add metric stream_limit_messages to expose the maximum messages limit for a stream (#341)
1 parent a175aa5 commit 6da52cd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

collector/jsz.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type jszCollector struct {
4747
streamConsumerCount *prometheus.Desc
4848
streamSubjectCount *prometheus.Desc
4949
streamLimitBytes *prometheus.Desc
50+
streamLimitMessages *prometheus.Desc
5051

5152
// Consumer stats
5253
consumerDeliveredConsumerSeq *prometheus.Desc
@@ -143,6 +144,13 @@ func newJszCollector(system, endpoint string, servers []*CollectedServer) promet
143144
streamLabels,
144145
nil,
145146
),
147+
// jetstream_stream_limit_messages
148+
streamLimitMessages: prometheus.NewDesc(
149+
prometheus.BuildFQName(system, "stream", "limit_messages"),
150+
"The maximum number of messages allowed in a JetStream stream as per its configuration. A value of -1 indicates no limit.",
151+
streamLabels,
152+
nil,
153+
),
146154
// jetstream_stream_total_bytes
147155
streamBytes: prometheus.NewDesc(
148156
prometheus.BuildFQName(system, "stream", "total_bytes"),
@@ -272,6 +280,7 @@ func (nc *jszCollector) Describe(ch chan<- *prometheus.Desc) {
272280
ch <- nc.streamConsumerCount
273281
ch <- nc.streamSubjectCount
274282
ch <- nc.streamLimitBytes
283+
ch <- nc.streamLimitMessages
275284

276285
// Consumer state
277286
ch <- nc.consumerDeliveredConsumerSeq
@@ -380,6 +389,7 @@ func (nc *jszCollector) Collect(ch chan<- prometheus.Metric) {
380389

381390
if stream.Config != nil {
382391
ch <- streamMetric(nc.streamLimitBytes, float64(stream.Config.MaxBytes))
392+
ch <- streamMetric(nc.streamLimitMessages, float64(stream.Config.MaxMsgs))
383393
}
384394

385395
// Now with the consumers.

0 commit comments

Comments
 (0)