Subject wise metrics in jetstream

55 views
Skip to first unread message

Roopali Maurya

unread,
Mar 30, 2024, 10:58:04 AM3/30/24
to nats
I am working with go code and using js.go. I see a jetStream.StreamInfo(streamName) ,the StreamState object returned in response has below map
Subjects map[string]uint64 `json:"subjects"` which should ideally have count of messages per subject, but I get nothing in this map. In what all ways can I get the count of messages subject wise in a stream?

Scott Fauerbach

unread,
Mar 30, 2024, 3:47:40 PM3/30/24
to nats
To get the Subjects map to be populated in the StreamState returned via StreamInfo, you must supply a SubjectsFilter in the StreamInfoRequest which is part of the optional jsOpts in the  StreamInfo function:

func (js *js) StreamInfo(stream string, opts ...JSOpt) (*StreamInfo, error)

The  SubjectsFilter string can be any valid subject filter. Use greater than to get all subjects for the stream.

Roopali Maurya

unread,
Apr 2, 2024, 6:18:07 PM4/2/24
to nat...@googlegroups.com
Hi Scott, If it is not too much trouble, can I please extend my question to below-

I am new to jetstream and I am working on creating a DLQ. The client who will subscribe will come every 10 days(let's say) to read messages from DLQ and it should be durable. So I have three requirements , which I have currently handled in below way-To be able to subscribe to DLQ (Durable and must have a worker queue)For this I have created a push based consumer, with below conf  and I do a queueSubscribe with some queueName.
config := SubscribeOptions{
        DeliverAllAvailable: true,
        IsManualAck:         true,
        IsPushBound:         true,
        DurableName:         subject,
    }
Also once a message is retried 3 times ,I send a msg.NakWithDelay(time.Duration(10) * time.Minute)To be able to read all unacked messages from DLQFor this also,I have done exactly like above ,same conf(same consumer), part of same workerqueue but for all messages I get I send a msg.NakWithDelay(time.Duration(2) * time.Minute)Get count of messages subject wise in DLQ.I use GetStreamInfo() , but here when i get the count subject wise, it give count of all messages subject wise, can i get count of all unacked messages someway.So I have three questions here -
Can this be done in a better way.
Also sending Nack and it constantly trying to redeliver messages for lets say 10 days, will it be resource intensive?
Better way to get count of unacked messages subject wise?

Thankyou!

--
You received this message because you are subscribed to a topic in the Google Groups "nats" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/natsio/J4QsXiKNE3w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to natsio+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/natsio/86d3f330-3d7d-4633-b60d-91de586f6b9cn%40googlegroups.com.
Message has been deleted

Scott Fauerbach

unread,
Jun 11, 2024, 5:48:27 PM6/11/24
to nats
I suggest you post this in the public slack https://natsio.slack.com/
Reply all
Reply to author
Forward
0 new messages