Skip to content
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

Allow exporting JetStream metadata as prometheus labels #317

Open
jkraml-staffbase opened this issue Nov 12, 2024 · 5 comments
Open

Allow exporting JetStream metadata as prometheus labels #317

jkraml-staffbase opened this issue Nov 12, 2024 · 5 comments
Labels
proposal Enhancement idea or proposal

Comments

@jkraml-staffbase
Copy link

What motivated this proposal?

We would like to route NATS-related alerts to responsible teams, but would not want teams to have to configure alert routing (complex and error prone). Instead, we'd like to enable them to add suitable metadata to JetStream streams/consumers (i.e. "team", "domain", "product", …) and have generic routing rules based on those.

What is the proposed change?

Provide configuration options to allow exporting select metadata values as Prometheus labels.

Who benefits from this change?

Anyone who'd like to group Prometheus metrics by some metadata like product/domain/etc. This is common based on e.g. k8s labels.

What alternatives have you evaluated?

  • Tedious manual config of alert routing
  • Building an additional tool visualize JetStream resource ownership (does not actually help with alert routing)
@jkraml-staffbase jkraml-staffbase added the proposal Enhancement idea or proposal label Nov 12, 2024
@jkraml-staffbase
Copy link
Author

I took the liberty of providing an example implementation.

@jkraml-staffbase
Copy link
Author

One might discuss whether stream and consumer labels should coalesce or not.

That is, if both stream and consumer have a metadata value for "product", should the resulting Prometheus metrics have two labels for this (e.g. stream_meta_product and consumer_meta_product) or should they be combined into one (e.g. meta_product, assuming the consumer label "wins")

@jkraml-staffbase
Copy link
Author

Another discussion point:

The exported values should be explicitly defined so as to avoid exporting all metadata as labels and accidentally creating high metric cardinality.

@ripienaar
Copy link

Agree with either specifically defined or prefix based metadata selection,

We're adding a bunch of metadata and I have a monitoring solution - that I am considering adding to the exporters - that does health checks on a per resource based based on metadata and it would become a lot

    "metadata": {
      "_nats.server.api_level": "1",
      "_nats.server.version": "2.11.0-dev",
      "io.nats.monitor.enabled": "1",
      "io.nats.monitor.lag-critical": "100",
      "io.nats.monitor.msgs-critical": "500",
      "io.nats.monitor.msgs-warn": "999",
      "io.nats.monitor.peer-expect": "3",
      "io.nats.monitor.seen-critical": "5m"
    },

@jkraml-staffbase
Copy link
Author

The linked PR currently allows defining stream and consumer metadata fields which are separately exported as metrics.
e.g. running with --jsz_consumer_meta_keys=foo --jsz_stream_meta_keys=bar will get you metrics with labels stream_meta_bar="…" consumer_meta_foo="…"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Enhancement idea or proposal
Projects
None yet
Development

No branches or pull requests

2 participants