Skip to content

Allow exporting JS metadata #318

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

jkraml-staffbase
Copy link

@jkraml-staffbase jkraml-staffbase commented Nov 12, 2024

Allow exporting selected JS metadata, e.g. to route alerts based on that.

Implementation of #317

Comment on lines +502 to +501
// NewJszCollector creates a new NATS JetStream Collector.
func NewJszCollector(
endpoint, prefix string,
servers []*CollectedServer,
streamMetaKeys, consumerMetaKeys []string,
) prometheus.Collector {
return newJszCollector(getSystem(JetStreamSystem, prefix), endpoint, servers, streamMetaKeys, consumerMetaKeys)
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a separate code path now for JetStream collectors to be able to supply the meta keys. This seemed better than to pass the arguments around for the other collectors where they wouldn't be used.

This makes JS collectors somewhat of a special case in the code, not sure if you like it that way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love it but it's probably the best option given the current organization of the code.

Comment on lines +83 to +87
for _, k := range streamMetaKeys {
streamLabels = append(streamLabels, "stream_meta_"+k)
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stream metadata is exported as labels named stream_meta_…, making sure they don't conflict with consumer metadata defined below.

Maybe it would actually be nice to combine these, WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is probably logical to keep them separated. There is potential for high cardinality but it would be self-imposed based on your own provided keys so that seems ok to me.

@jkraml-staffbase jkraml-staffbase force-pushed the export-metadata-values branch 2 times, most recently from a853ce9 to 8ebe945 Compare March 3, 2025 12:49
@jkraml-staffbase jkraml-staffbase force-pushed the export-metadata-values branch from bedba8f to fbde41a Compare April 1, 2025 14:47
Copy link
Member

@samuelattwood samuelattwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution; apologies for the long tail on this. Just a few comments

Comment on lines +83 to +87
for _, k := range streamMetaKeys {
streamLabels = append(streamLabels, "stream_meta_"+k)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is probably logical to keep them separated. There is potential for high cardinality but it would be self-imposed based on your own provided keys so that seems ok to me.

Comment on lines +502 to +501
// NewJszCollector creates a new NATS JetStream Collector.
func NewJszCollector(
endpoint, prefix string,
servers []*CollectedServer,
streamMetaKeys, consumerMetaKeys []string,
) prometheus.Collector {
return newJszCollector(getSystem(JetStreamSystem, prefix), endpoint, servers, streamMetaKeys, consumerMetaKeys)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love it but it's probably the best option given the current organization of the code.

suggestion in PR 318
do not reify extraction functions, just pass keys around
suggestion in PR 318
add new cmd line opts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants