gnmic icon indicating copy to clipboard operation
gnmic copied to clipboard

jetstream input stream stop processing metrics due to missing retention policy setting

Open marco-minervino opened this issue 3 months ago • 5 comments

Hello, I noticed that the jetstream input doesn't have an option to set a RetentionPolicy; this causes the stream to stop ingesting metrics as the jetstream global limits (defined in nats.config, like max_file_store) are reached, even if the messages were consumed and ack'ed normally and can be discarded from nats stream. It would be useful to have a way to define the RetentionPolicy so the metrics can be discarded once they are consumed.

marco-minervino avatar Sep 29 '25 08:09 marco-minervino

looking at it.

protonjhow avatar Sep 29 '25 08:09 protonjhow

Retention policy is not something the consumer sets, it's a property of the stream. If you use gNMIc Jetstream Output to create the stream, the retention policy is kept to the default value LimitsPolicy. You can set the stream limits: max_msgs, max_bytes, and max_age at creation time. If you want to use a different retention policy than Limits, you will have to create the stream on your own.

karimra avatar Sep 29 '25 14:09 karimra

i would like to get a small patch in that enables the user to pick up the WorkQueue pattern. this is much more aligned to the goals here, and the limits policy seems to not work as expected (we have limits set, but its not taildropping old messages as expected - which i am looking into separately)

protonjhow avatar Sep 30 '25 09:09 protonjhow

i would like to get a small patch in that enables the user to pick up the WorkQueue pattern. this is much more aligned to the goals here, and the limits policy seems to not work as expected (we have limits set, but its not taildropping old messages as expected - which i am looking into separately)

This would be done on the publisher side (jetstream output in case of gNMIc), during the stream creation (which is optional for the jetstream output). Today it's possible to entirely skip the stream creation by the publisher (output) and create the stream manually before the publisher and consumer start.

karimra avatar Oct 09 '25 23:10 karimra

so its not so much of a "small patch". i wanted to make it backwards compatible and optional and handle the mutual exclusion configs that it produces.

i tried a bit on my own at first, but honestly it was not going so well, so I put together a PR with claude helping out. some people are religious about this, i understand that perspective too. imho this doesnt qualify as slop, but constructive comments are welcome 😃

the result is what i wanted this change to do, it worked in my own environment, and i was able to test all the edge cases i could thing of to ensure it works as expected for others too. i updated the docs and the testing harness to account for the additions as well.

protonjhow avatar Oct 26 '25 13:10 protonjhow