-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Support for Jetstream in NATS output plugin #14235
Comments
Thank you for the issue and the PR! next steps: review PR |
@powersj I need your inputs. If we want to publish any message to NATS, we require a subject and the message itself. This is valid for both NATS core and Jetstream. Jetstream essentially maps a subject to a stream(persistent store). So technically, telegraf can post messages to a stream if the subject provided in the config is a part of a stream and that the stream exists. This is done on the server side, so the clients don't have to worry about it. We need to define the behaviour of telegraf now-
Essentially the problem is not about publish, but about configuring the stream. Because even without jetstream, the NATS API supports publishing to a stream. Let me know your thoughts. |
Hi, Thanks for the update and scenarios.
excellent, so really the remaining concern is when the server is not set up with a stream and/or subject?
I think Telegraf should create the stream. We could try to do this once per start up, where we check if the subject exists and if not create it. Is that possible?
I think this should also be an option in order for us to claim support for streams as well. |
Subject to stream is a 1-1 mapping, while stream to subjects is n-1 mapping. We can check if the subject exists via func StreamNameBySubject(ctx context.Context, subject string) (string, error) This will return the stream name for the subject if it exists, or error if no such stream exists or jetstream is not enabled on the server.
That leaves us with the important question- If we are creating the stream, should we consider the Subjects present in the config and append the subject from the nats(since we used this to check for stream) or simply overwrite the Subjects field with this subject. PS: Subjects is an array and is optional. If not provided it will create one using the stream name itself which is mandatory! |
Let me turn the tables around and ask you as a user of Streams what would you prefer? A more explicit approach where what we have in telegraf is what we do, or do we always try to see what the server has? The more scenarios you provide, the more concerned I become with us trying to do things for the user, and lean more towards an explicit approach. Where we do whatever the telegraf config says. If the stream doesn't exist, we create it and in all other cases we just do what the user told us to do. That config could include reading a stream value from a tag for example, or be explicitly defined in the config. Thoughts? |
@neelayu - was there additional work you wanted to do then to support jetstream in nats to cover the additional cases? Or is what is present sufficient? |
Thanks for your response. I think I covered everything in my last commit. Let me know your thoughts. |
Use Case
NATS Jetstream supports persistence of messages and currently telegraf only supports publishing messages to NATS core.
It can read from Jetstream via nats_consumer input plugin, however publishing is missing.
Expected behavior
Allow configuration for Jetstream in NATS output plugin and publish metrics to it.
Actual behavior
Not supported
Additional info
No response
The text was updated successfully, but these errors were encountered: